Frage

I have a class that uses "org.apache.ant" and the class is very simple, it's not even in a package.

So I simply use javac MyClass.java to compile it, of course, I got this error saying package "org.apache.ant" not found.

I've downloaded the artifact. So how do I specify the source of the library in the javac command?

Thanks

War es hilfreich?

Lösung

Use classpath to include the package after you compile.

It might look something like this...

javac -classpath .;org.apache.ant.jar MyClass
java -classpath .;org.apache.ant.jar MyClass

Refer to this link for more information. Help with packages in java - import does not work

Update Following the Ant Installation tips here. https://supportweb.cs.bham.ac.uk/docs/tutorials/docsystem/build/tutorials/ant/ant.html

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top