I'm trying to execute my JAVA
app on a Linux
OS where the necessary jars are located in a different folder. How can I execute my project using the external jars?
project location:
$ pwd
/root/MyApp/bin
$ ls
Deletion.class
jars location:
/opt/jars/*.jar
My failed execution:
$ java Deletion
... NoClassDefFoundError ...
$ java -cp "/opt/jars/*.jar" Deletion
Error: Could not find or load main class Deletion
使用-cp ...
设置类路径时,还必须指定当前的工作目录(因为该目录已不再存在):
java -cp ".:/opt/jars/*.jar" Deletion
java -cp "location of jar file:." Deletion
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.