David Rasuli
David Rasuli

Reputation: 832

Compile a java file that depends on a jar file

I have the following files, both has the same package definition:

awesome.java
awesomeTest.java

the package (and directories) for these files is : package awe.some

I try to compile them in command line However they don't seem to compile, since awesomeTest.java use import junit.framework.*;

How do I compile this properly in command line?

Thanks.

Upvotes: 0

Views: 57

Answers (2)

JB Nizet
JB Nizet

Reputation: 691635

Same as for running java classes: the jar must be in the classpath for the compiler to be able to load the classes it contains:

javac -cp /path/of/junit-4.1.jar awe/some/awesomeTest.java

Note that classes from junit.framework are obsolete in JUnit4. You should not use them anymore for new tests.

Upvotes: 1

Reimeus
Reimeus

Reputation: 159754

Try this

javac -cp junit-4.1.jar;. awe/some/*.java

Upvotes: 1

Related Questions