1

I am running jar file from command prompt to copy text file from one folder to other using command.

java.exe -jar CopyFile.jar D:\abc\hello.txt E:\copy\hellocopy.txt

I tried like this:

Runtime.getRuntime().exec("java.exe -jar "+jarFilePath+"CopyFile.jar" +" "+ filePath +" "+ copyFilePath);

I want to execute same jar file with 2 parameters from java program. How can use this command in other java program.

Jens
  • 67,715
  • 15
  • 98
  • 113
jagannath
  • 93
  • 2
  • 11

1 Answers1

0

I solved like this:

String cmd= "java -jar "+currentDir+"\\CopyFile.jar "+inFile+" "+outFile;   
Runtime.getRuntime().exec(cmd);
codebot
  • 2,540
  • 3
  • 38
  • 89
jagannath
  • 93
  • 2
  • 11
  • Runtime.getRuntime().exec(cmd); I want to check file is copied or not? Will this return any value => Runtime.getRuntime().exec(cmd); – jagannath Jun 24 '15 at 07:40