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这点很容易作到)

解决方案 »

  1.   

    often we put all the third-party jars, utils jars into one or two folders named lib.so you can add them into classpath in the manifest.mf of the target jar. 
    I don't think it won't work with absolute path, remember the difference between \ and / in Windows.
      

  2.   

    错误信息如下:
    Exception in thread "main" java.lang.NoClassDefFoundError: testOne/Main用相对路径则没问题。
      

  3.   

    java -jar -Dclasspath=testTwo.jar testOne.jar指定classpath参数肯定可以!另外关于绝对路径问题,参见:http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.htmlClass-Path: servlet.jar infobus.jar acme/beans.jar
    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. 只能用相对路径。
      

  4.   

    sorry for my poor knowledge on the absolute path and relative path...