ant – Cannot find package org.junit when compiling java file in command prompt
ant – Cannot find package org.junit when compiling java file in command prompt
You need to put junit.jar on the classpath when you compile and then when you run the class.
Please refer to the manual entries for the java
and javac
commands, and also to the page on setting the classpath.
If you are building from the command line using Ant, then you need to make sure that your build.xml sets the compilation classpath correctly.
You will also need to add import
statements to import any Junit 4 annotations that you use. But you need to address the package org.junit does not exist issue first.
I faced the same problem and added the Junit file path to the classpath and that solved it. Be aware that User Environment variable takes precedence over the system environment variable when the EV exists in both.