开发者

Run java without specifying classpath on the command line

开发者 https://www.devze.com 2023-04-10 14:09 出处:网络
I\'ve specified the main class and classpath for a java program in the .jar file manifest, but occasionally I want to run a different class from the one specified by the Main-Class attribute. Can I ge

I've specified the main class and classpath for a java program in the .jar file manifest, but occasionally I want to run a different class from the one specified by the Main-Class attribute. Can I get java to launch this class while still pulling the classpath from the manifest, so that I don't have to开发者_JS百科 specify the whole thing on the command line with -cp?


Just put the jar file on the command line with -cp; Java will then observe the classpath attribute within the manifest, even though you're not using -jar:

java -cp app.jar MyOtherClass
0

精彩评论

暂无评论...
验证码 换一张
取 消