开发者

Is classpath, junit.jar and import org.junit statement in Eclipse independent?

Are classpath, junit.jar and import org.junit statement independent of each other in Eclipse? After adding junit.jar on Windows 7 (environment) classpath I am not able to benefit from importing org.junit.*; statement in Eclipse for Java. Eclipse 开发者_运维知识库informs that the import org.junit cannot be resolved. Is it normal behaviour? By using command line (cmd.exe) junit works fine:

java org.junit.runner.JUnitCore org.junit.tests.AllTests

However, within Eclipse I cannot use Junit classes.


The project build path is in charge in Eclipse. If junit.jar (of appropriate version) or the JUnit eclipse lib are on the build path, you can import junit classes. If not, not. The classpath environment variable is never a good idea.


Eclipse builds classpath to based upon what is called a 'build path' and invokes JVM with a -cp argument. JVM ignores CLASSPATH env variable if an explicit -cp jvm arg is passed to it so your Windows classpath setting is ignored.

Solution: set up your project build path correctly ie. add your jars there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜