when using RunTime.exec(), one can specify the working directory of the subprocess (very useful, if the executed app can only be launched from its location as it access some local config files for instance)
If the external app is a jar file, on can read the manifest in the jar to get information about the main class and the classpath and then call invoke() to run the application…
Is there a way to set the working directory there too ? I cannot seem to find a way for doing that? Or do I have to use RunTime.exec() and actually make a call to ‘java -jar app.jar’…
thanks in advance for your help
David
I would say that if you have an application that you have written that depends on what the working directory is set to you have done it wrong. Make use of Class.getResource and Class.getResoruceAsStream and passing fill paths to the arguments for “main(String[])” to remove path dependencies.
Also there is the System.getProperty(“user.dir”); method to get the working direcvtory, but you cannot call System.setProperty(“user.dir” … ) to change it.