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 specify the whole thing on the command line with -cp
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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