I am calling the batch file with the following method as the main method:
public Static zero main (string algos []) {runtime RT = runtime.greatantum (); Try {processing pr = rt.exec ("D: \\ test1.bat"); Pr.waitFor (); } Hold (exception e) {e.printStackTrace (); }}
The content of the batch file is as follows:
xcopy d: \ a1d: \ a2 call C: \ Java \ jdk1 6.0_27 \ bin \ Java.exe -version> gt1.10x 2x & amp; 1
Copying files from folder A1 to A2 folder, but log1.txt is not being generated though if I click this batch file twice , Then copying files and getting 1.txt logs with Java version ready.
- This will probably occur in the current working directory of log1.txt Java application, which There is no directory similar to the .bat file.
- If you are mentioning that you are using Eclipse, this sets the work directory by default, unless you have changed it, which is the application directory point (static zero main ) Is at the top level of the project directory.
-
Eclipse does not automatically refresh the file system when external changes are made - try selecting the project, and file => Refresh (F5)
-
There is an overloaded version of Runtime.exa () that lets you set up a working directory as a third parameter.
Example
public static zero major (string algos []) {runtime RT = runtime.greatantum (); Try {process pr = rt.exec ("D: \\ test1.bat", tap, new file ("D: \\")); Pr.waitFor (); } Hold (exception e) {e.printStackTrace (); }}
No comments:
Post a Comment