Relaunching a jar from within itself?

83 views Asked by At

I am looking to relaunch a program I've written programmatically without knowing the name of the jar it's contained in. I know there's a way to do it if it's a class by doing Runtime.getRuntime().exec(new String[]{"javaw", getClass().getName()}); but how would I do it with a jar. I thought about running the class using the -cp argument but even then I still need the name of the jar. I'm actually thinking it's not possible given that the name of the jar has no programmatical significance but maybe I'm wrong.

1

There are 1 answers

0
MeBigFatGuy On BEST ANSWER

you can use System.getProperty("java.class.path") to get the class path used to launch 'this' program.