Soheil
Soheil

Reputation: 627

run java file which depends on another java class

I have developed a java class (A) which calls another java class (B) and also uses external library lib.jar. all of the classes and jar files have been uploaded to /home/admin/ directory.

now I want to run class A on centos.

javac -cp /home/admin/lib.jar /home/admin/A.java /home/admin/B.java

and then:

java -cp /home/admin/lib.jar /home/admin/A.java

but it says: cannot find symbol: class B. how to solve the problem?!

Upvotes: 0

Views: 118

Answers (1)

Edgar Domingues
Edgar Domingues

Reputation: 990

You must include the directory /home/admin in the claspath:

java -cp /home/admin/lib.jar:/home/admin A 

You also don't need to call java with the A.java file. You can call it with the class name A directly.

Upvotes: 1

Related Questions