itaied
itaied

Reputation: 7107

Running a JAVA project with external jars folder

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

Upvotes: 0

Views: 41

Answers (2)

Seelenvirtuose
Seelenvirtuose

Reputation: 20658

When setting the class path with -cp ..., you have to also specify the current working directory (as this is not part anymore):

java -cp ".:/opt/jars/*.jar" Deletion

Upvotes: 1

Shriram
Shriram

Reputation: 4421

java -cp "location of jar file:." Deletion

Upvotes: 0

Related Questions