简体   繁体   中英

Relaunching a jar from within itself?

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.

您可以使用System.getProperty(“ java.class.path”)获取用于启动“此”程序的类路径。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM