设置类路径 [英] Setting the classpath
本文介绍了设置类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个执行1个任务的shell脚本。
hi i have written one shell script which is performing 1 task.
java -jar abc.jar $* -adminid $j_username
在此命令之前,我想设置所有jar的类路径(或要引用)特别是lib文件夹,该怎么办?
before this command i want to set classpath(or want to refer) of all jars which are in particular lib folder, how to do that?
推荐答案
一种解决方法是:
set CP=abc.jar:someother.jar
java -cp $CP your.main.Class $* -adminid $j_username
值得一提的是,当使用 -jar
时,不能在其上指定其他JAR /资源classpath即 -cp
开关被忽略,因此您必须在两者之间进行选择。
It is worth while to note that when using -jar
you can't specify other JARs/resources on the classpath i.e. -cp
switch is ignored hence you would have to choose between the two.
- 创建一个独立的JAR,其中
合并了其他JAR /资源 - 使用不同的JAR文件,但使用$
-jar code>在运行程序时指定主要的
类
- Create a standalone JAR which incorporates other JARs/resources
- Have different JAR files but instead
of using
-jar
specify the main class when running the program
这篇关于设置类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文