0

To perform the following actions, what shall be needed.

Action-1 : Execute an executable file from a folder.
Action-2 : Copy all the files from a Folder to the installed 
           directory of the above executable.

I need an executable to perform the above two actions. After research, i could find that i can do this in JAVA as a JAR file or by using a shell script. Can someone please guide me the way these can be done effectively. Please tell me what shall i choose.

EDIT

So, JAVA is the only option here?

  • What about making a VBScript to do this, would that be easier.
  • What about the Second Action, how shall that be done?

please comment the possibilities

EDIT 2

Action - 1 can be done like this ( thanks 2 jake) in a bat file

"xcopy /s DirectoryToCopy ProgramDirectory"

To monitor that Action-1 is complete and then perform the Action-2. After completion of the execution only, the Action-2 should start. can someone please guide me which condition shall i give in the script.

  • how to perform execution of an exe through the bat
  • how to monitor the completion of the above
  • how to copy the file contents
Syamili V
  • 53
  • 1
  • 10

2 Answers2

0

Yes you can use Jars to do this, infact jars are great for this sort of thing as all the program files can be put in the executable jar as well as the compiled .class files so they can be shipped really cleanly. Compiling jars can be really messy so I prefer to use an IDE but whatever floats your boat is good. Jars are just a modified form of a zip so if you have 7 zip or other archiving applications you can add, modify or delete enties from the jar.

To actually copy the contents of the JAR you can use the ZipEntry APIs in java.util

  • :thanks----- to copy just files from one folder to another using a command in the JAR exceutable is what iam looking... – Syamili V Mar 11 '15 at 14:26
  • so are you writing a program in java to move to contents of a file to another location? If so then it would probably be more convenient to write a shell script. Are you on windows? – Jake O'Neill Mar 11 '15 at 20:33
  • If you wish to copy the contents of a directory to the installed directory you can use the xcopy command in a batch file. To create a batch(.bat), make a new text file, hit save as, change *.txt to "all files" and name the file what you want with the extension .bat. You can then edit this and add the xcopy command which will look something like this: "xcopy /s DirectoryToCopy ProgramDirectory". The /s argument here copies all the directories and subdirectories as long as they are not empty – Jake O'Neill Mar 12 '15 at 11:05
  • THANKS@Jake ... one more issue. how to monitor that Action 1 is complete and then perform this Action-2. – Syamili V Mar 12 '15 at 14:18
  • I recommend that you execute the program before copying the files in the batch. To execute a program from a batch you just need to specify the path and the executable for example C:\afolder\myexecutable.exe – Jake O'Neill Mar 12 '15 at 14:50
0

Have a look at Process to launch an external program and then this

Community
  • 1
  • 1