I am executing a batch file from java program.
When I execute from eclipse it works fine but when I make it a runnable jar it is not able to find the path of the batch file
I kept the batch file as a resource in the source directory.
When I print the path of the resource using Class.getResource(“/resource/mybat.bat”) it gives the path correctly as
- resources/mybat.bat(jar creation option : package required library into generated jar)
- file:/C:/Users/aasha.medhi/Desktop/myjar.jar!/resources/mybat.bat(jar creation option : Extract required libraries into generated jar)
If I extract the jar, the resources folder exist.
However when I try to run the jar, it gives “The system cant find the path specified error” for the batch file
I have gone through most of the links and tried out different options but without any luck.
I just need a way to create the runnable jar properly.Please help..
While Java can read JARs and treat them just as the normal file system, most other applications cannot. In this case
cmdcan’t. You have to extract the batch to a temporary location and run it from there.