[英]Broken Eclipse project - classNotFoundException - could not find main class
I have a project I've been developing in Eclipse 3.7.2 on Ubuntu 12.04. 我有一个项目,我一直在Ubuntu 12.04上的Eclipse 3.7.2中开发。 Recently, I've restructured the class hierarchy which involved moving classes between packages. 最近,我重新构建了包含在包之间移动类的类层次结构。 I did not move my main class ("ob3.converter.Converter"), which contains my public static void main(String[] args)
method. 我没有移动我的主类(“ob3.converter.Converter”),它包含我的public static void main(String[] args)
方法。
Now, when I attempt to run it, I get: 现在,当我尝试运行它时,我得到:
Exception in thread "main" java.lang.NoClassDefFoundError: ob3/converter/Converter
Caused by: java.lang.ClassNotFoundException: ob3.converter.Converter
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: ob3.converter.Converter. Program will exit.
I've only ever really worked (in java) with Eclipse, which handles all the overhead for me - hence I have little understanding of this error or what could cause it. 我只是用Eclipse工作(在java中),它为我处理所有开销 - 因此我对这个错误或者可能导致错误的理解很少。 I've looked through my Run Configuration/Classpath etc but without knowing what to look for, it was fruitless. 我查看了我的运行配置/类路径等,但不知道该寻找什么,它没有结果。
Could anybody point me in the right direction? 有人能指出我正确的方向吗? I've googled / search SO, and most things talk about a manifest file, but I've been unable to find it anywhere. 我用google搜索/搜索SO,大多数事情都是关于清单文件,但我无法在任何地方找到它。 My workspace folder contains nothing more than my source files. 我的工作区文件夹只包含我的源文件。
I can verify: 我可以验证:
public static void main(String[] args)
method. “Converter”类包含一个public static void main(String[] args)
方法。 Any help is very much appreciated! 很感谢任何形式的帮助!
I think you should rebuild your project. 我认为你应该重建你的项目。 You can do this by clicking on Projects > Clean... 您可以通过单击Projects> Clean ...来执行此操作
Sometimes the automatic build of Eclipse has problems with the refactoring or moving of classes. 有时,Eclipse的自动构建存在重构或移动类的问题。
I ran into this same error message. 我遇到了同样的错误消息。 For me, I was on linux and the user issuing the java command did not have sufficient permissions to the directory of the jars on the classpath. 对我来说,我在linux上,发出java命令的用户对类路径上的jar目录没有足够的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.