testOne.jar 需要用到 testTwo.jar在命令行中用:
java -jar testOne.jar (试过用-classpath 但是不起作用)所以通过testOne中的Manifest.mf加入
Main-Class: testOne.Main
Class-Path: testTwo.jar情况是:
1。如果我把它们放在同一目录下,运行正常。
2。不在同一目录,在Class-Path行使用-相对目录,运行正常
3。不在同一目录,在Class-Path行使用-绝对目录,运行不正常,提示找不到Main Class。因为如果这个包要访问很多其他目录下的包,这就很麻烦了。
难道都要copy到同一目录下吗?注意:现在在命令行下作,不使用任何IDE(用Eclipe这点很容易作到)
java -jar testOne.jar (试过用-classpath 但是不起作用)所以通过testOne中的Manifest.mf加入
Main-Class: testOne.Main
Class-Path: testTwo.jar情况是:
1。如果我把它们放在同一目录下,运行正常。
2。不在同一目录,在Class-Path行使用-相对目录,运行正常
3。不在同一目录,在Class-Path行使用-绝对目录,运行不正常,提示找不到Main Class。因为如果这个包要访问很多其他目录下的包,这就很麻烦了。
难道都要copy到同一目录下吗?注意:现在在命令行下作,不使用任何IDE(用Eclipe这点很容易作到)
I don't think it won't work with absolute path, remember the difference between \ and / in Windows.
Exception in thread "main" java.lang.NoClassDefFoundError: testOne/Main用相对路径则没问题。
With this header, the classes in the files servlet.jar, infobus.jar, and acme/beans.jar will serve as extensions for purposes of the applet or application. The URLs in the Class-Path header are given relative to the URL of the JAR file of the applet or application. 只能用相对路径。