I have used the more student-oriented IDE DrJava before, and did not have trouble running programs dependent on .jar files in the terminal/command line.
Right now I am writing a simple program to find eigenvalues of matrices in IntelliJ, and although I have followed the steps listed in the stack overflow question "Importing jar file into IntelliJ Idea?" to add the .jar file I am using as a dependency, I am getting errors like this when I try to compile the program in terminal:
javac eigenvalues.java
eigenvalues.java:11: error: package Jama does not exist
import Jama.*;
^
and etc. (more errors of the form such-and-such does not exist).
My program has multiple classes and I only need the .jar file for one of them.
The program compiles fine within intelliJ, just not from terminal.
You can make it work by two ways: 1. You can try by putting the required JAR in the ext folder: Below is the path to ext folder, then try to compile.
On Linux Systems - /urs/lib/JDK/jre/lib/ext/
On Windows Systems- C:/Program Files/Java/jdk..0.1/jre/lib/ext/
You can add the path of that required jar to the CLASSPATH system variable also.
You can compile the program by dynamically providing the classpath with javac command as below:
javac -classpath "<Path to the JAR>" YourProgram.java
There is a very good link on the classpath .
Hope It may work.
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.