Reputation: 113
I am trying to compile my Java program which relies on external libraries. The program compiles without errors in the IDE. Upon compiling in a terminal, I am faced with the compiler not recognizing the code that I have written. All files are in the same directory. I am using a Makefile.
The following is the javac call and the resulting errors that arise. All Java and Jar files are in the current directory.
$ javac -cp "./*" Driver.java
Driver.java:22: error: cannot find symbol
DataSetProcessor processor = new DataSetProcessor();
^
symbol: class DataSetProcessor
location: class Driver
Driver.java:22: error: cannot find symbol
DataSetProcessor processor = new DataSetProcessor();
^
symbol: class DataSetProcessor
location: class Driver
Driver.java:29: error: cannot find symbol
HashMap<Integer, Dealer> map = processor.getDealerVehicleRelationship(dataSetID, vehicleIDsList);
^
symbol: class Dealer
location: class Driver
3 errors
Dealer.java & DataSetProcessor.java are in the current directory.
Can someone please explain to be what my problem is? I can't understand it.
Upvotes: 1
Views: 2050
Reputation: 1932
You should do the following :
$ javac -cp "lib/*:." Driver.java
Upvotes: 3
Reputation: 113
My use of the -cp was wrong. I am using Mac; I'm not sure if that is the reason.
The final compiler call is now:
$ javac -cp lib/commons-io-2.6.jar:lib/json-20180813.jar:. Driver.java
and the call to run the program is:
$ java -cp lib/commons-io-2.6.jar:lib/json-20180813.jar:. Driver
Upvotes: 0