Reputation: 5938
I am coding in simple text document and executing java code with command line with javac command. i want to use jar file which is in directory like /abc/public/assi1 and i have code which is in directory like /abc/assi1. I am including the jar file with import statement in the class myClass.java which is in directory /abc/assi1/myClass.java i am getting errors.
It is not recognizing the things which are in the jar file.
Could some one please help in this.
Thanks
Upvotes: 0
Views: 404
Reputation: 1238
The jar has to be inside your java path.
You have to write something like this.
javac -classpath \path\to\lib.jar src.java
Upvotes: 2
Reputation: 786271
You can compile your code like this from the directory /abc/assi1:
javac -cp .:/abc/public/assi1/your.jar -d . your-java-class.java
Then you can run your code like this from the directory /abc/assi1:
java -cp .:/abc/public/assi1/your.jar your-java-class
-cp
option sets the class path for you on command line. It adds the required jar file and the current directory .
into your class path.
Upvotes: 4