无法找到或加载主类org.junit.runner.JUnitCore [英] Could not find or load main class org.junit.runner.JUnitCore

查看:499
本文介绍了无法找到或加载主类org.junit.runner.JUnitCore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将测试类打包到JAR中.我在同一文件夹中有junit-4.10.jaraJar.jar.当我尝试执行时:

I packed test classes into JAR. I have junit-4.10.jar and aJar.jar in the same folder. When I try to execute:

java -cp .:junit-4.10.jar org.junit.runner.JUnitCore TestOne

Error: Could not find or load main class org.junit.runner.JUnitCore

如何使其工作?

当我键入:java aJar.jar:junit-4.10.jar org.junit.runner.JUnitCore TestOne

我得到

Error: Could not find or load main class aJar.jar:junit-4.10.jar

推荐答案

您似乎在Windows而不是LINUX/UNIX下运行. Windows上的路径分隔符是;,而不是:.此外,您还没有将jar文件放在类路径中.所以你想要的是:

You seem to be running under Windows, not LINUX/UNIX. The path separator on Windows is ;, not :. Additionally, you haven't put you jar file in the classpath. So what you want is:

java -cp aJar.jar;junit-4.10.jar org.junit.runner.JUnitCore TestOne

这当然假定两个jar都在当前目录中.您还应该始终避免将类放入默认包中.

This of course assumes that both jars are in the current directory. You should also always avoid putting classes in the default package.

这篇关于无法找到或加载主类org.junit.runner.JUnitCore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆