Does java -jar option alter classpath options

前端 未结 3 1860
悲哀的现实
悲哀的现实 2021-01-12 17:12

I have a jar file which mentions the main class in the manifest. When I try to execute the jar using the following command

java -cp .;./* com.foo.MainClass
<         


        
相关标签:
3条回答
  • 2021-01-12 18:01

    Here is a good discussion on this issue.

    0 讨论(0)
  • 2021-01-12 18:08

    You will need your own classloader to deal with this. -jar only respects the information in the Manifest and wildcards are not allowed there.

    You might find the example of a reloadable class useful: http://www.exampledepot.com/egs/java.lang/ReloadClass.html

    0 讨论(0)
  • 2021-01-12 18:09

    From this,

    An executable JAR must reference all the other dependent JARs it requires through the Class-Path header of the manifest file. The environment variable CLASSPATH and any class path specified on the command line is ignored by the JVM if the -jar option is used.

    0 讨论(0)
提交回复
热议问题