I can't make javac recognize an external .jar file, whose classes I'm trying to extend. I have two files in the same directory: TestConsole.java and acm.jar. I'm compiling from the same directory using the following command:
javac -classpath .:acm.jar TestConsole.java
But it seems like javac is just ignoring acm.jar. It gives me the error:
TestConsole.java:1: package acm does not exist
import acm.program;
^
Of course, acm.program is a package in acm.jar. All of the classes in acm.jar are already compiled; I just want to use them in my classes, not compile them.
What am I doing wrong?
I am running this on a Mac, and the directory structure of acm.jar appears to be valid: It contains an acm/program
directory, which has ConsoleProgram.class
, the only class that TestConsole
extends.
javac -classpath ".:acm.jar" TestConsole.java
does not work, either.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…