I currently have the following problem:
I have two java applications: updater and client. The updater is a native application (which contains the necessary JDK), while the client is just a runnable jar file.
When the user starts the application, it basically starts the updater, which searches for an update for the client application on the server. When a new update is present, the updater downloads the update and places it in a file (or overwrites the current jar file). Then, I execute the downloaded .jar file like this:
private void startApplication() {
Runtime rt = Runtime.getRuntime();
try {
Process pr = rt.exec("java -jar libs/myJar.jar");
} catch (IOException e) {
e.printStackTrace();
}
}
This works fine when building and running in Eclipse, but when I run the native application (which is built by Eclipse) myJar.jar doesn't get executed. I think it is due to the fact that the updater can not find the jar file, because it absolute path becomes different.
My question: How can I make sure that the native application can execute the downloaded jar file?
Note: I am currently building the app on Mac OSX, so I am testing this with a .dmg. I don't know if the problem is also present for Windows or Linux.
Edit 1: It doesn't seem to be a problem with the path, because this seems to be fine (as tested with @Funtik, thank you for that).
Edit 2: The file permissions also seem to be correct. Maybe it has something to do with the fact that the client jar doesn't know which JVM to use?
You have to use absolute path for this.