[英]Including jar files in class path
我从一个批处理文件中运行一个java程序,它重新添加了一些外部jar文件。如何在我的批处理文件中包含这些jar文件。请帮助
Look at the Sun's official documentation: Setting the class path to understand your options. 查看Sun的官方文档: 设置类路径以了解您的选项。
A quick way would be just to include your JAR(s) after the -cp
: 一个快速的方法就是在
-cp
之后包含你的JAR:
java -cp C:\java\MyClasses\myclasses.jar;C:\java\MyClasses\myclassesAnother.jar utility.myapp.Cool
java -cp /opt/thirdparty/myclasses.jar:/opt/thirdparty/myclassesAnother.jar utility.myapp.Cool
You need to set classpath http://download.oracle.com/javase/1.3/docs/tooldocs/win32/classpath.html . 您需要设置classpath http://download.oracle.com/javase/1.3/docs/tooldocs/win32/classpath.html 。 Eg,
例如,
java -cp file1.jar;file2.jar yourApp
or if your jar-files are located in directory lib/
或者如果你的jar文件位于
lib/
目录中
java -cp lib/* yourApp
Not to bother with -classpath parameter you could put references to the jar files into the manifest.mf of your application JAR, if it's you application of course. 不要打扰-classpath参数,你可以将jar文件的引用放到应用程序JAR的manifest.mf中,如果它是你的应用程序的话。
You have to fill the Class-Path parameter of the manifest file of the JAR. 您必须填写JAR清单文件的Class-Path参数。 The standard documentation explains that very well.
标准文档很好地解释了这一点。
Sorry, I dont know others IDE, but works with me on Eclipse. 对不起,我不认识其他IDE,但在Eclipse上与我合作。
Right click on your project, select 右键单击您的项目,选择
Properties/ Java Build Path/ Libraries/ Classpath/ Add External JARs...
属性/ Java构建路径/库/类路径/添加外部JAR ...
Then choose whatever files you need :v 然后选择您需要的任何文件:v
运行jar或类文件时,请指定classpath选项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.