运行 带有外部 jars 文件夹的 JAVA 项目
Running a JAVA project with external jars folder
我正在尝试在 Linux
OS 上执行我的 JAVA
应用程序,其中必要的 jars 位于不同的文件夹中。如何使用外部 jar 执行我的项目?
项目位置:
$ pwd
/root/MyApp/bin
$ ls
Deletion.class
罐子位置:
/opt/jars/*.jar
我执行失败:
$ java Deletion
... NoClassDefFoundError ...
$ java -cp "/opt/jars/*.jar" Deletion
Error: Could not find or load main class Deletion
java -cp "location of jar file:." 删除
当使用 -cp ...
设置 class 路径时,您还必须指定当前工作目录(因为这不再是一部分):
java -cp ".:/opt/jars/*.jar" Deletion
我正在尝试在 Linux
OS 上执行我的 JAVA
应用程序,其中必要的 jars 位于不同的文件夹中。如何使用外部 jar 执行我的项目?
项目位置:
$ pwd
/root/MyApp/bin
$ ls
Deletion.class
罐子位置:
/opt/jars/*.jar
我执行失败:
$ java Deletion
... NoClassDefFoundError ...
$ java -cp "/opt/jars/*.jar" Deletion
Error: Could not find or load main class Deletion
java -cp "location of jar file:." 删除
当使用 -cp ...
设置 class 路径时,您还必须指定当前工作目录(因为这不再是一部分):
java -cp ".:/opt/jars/*.jar" Deletion