Setting the classpath

纵然是瞬间 提交于 2019-12-14 04:09:07

问题


hi i have written one shell script which is performing 1 task.

java -jar abc.jar $* -adminid $j_username

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?


回答1:


set CLASSPATH=pathtojars1;pathtojars2

before your java command.

Or:

java -classpath 



回答2:


One way to do it would be:

set CP=abc.jar:someother.jar
java -cp $CP your.main.Class $* -adminid $j_username

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.

  • 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


来源:https://stackoverflow.com/questions/4590739/setting-the-classpath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!