线程“main”中的异常 java.lang.ClassNotFoundException:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27871379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exception in thread "main" java.lang.ClassNotFoundException:
提问by kayanushpatel
I recently installed intellij IDEA 14.0 and to make sure everything was working I created a simple Hello World program. I do not understand why the output is not correct and why I am getting this error. If someone could please help that would be great.
我最近安装了 intellij IDEA 14.0 并确保一切正常,我创建了一个简单的 Hello World 程序。我不明白为什么输出不正确以及为什么我会收到此错误。如果有人可以请帮助那就太好了。
This is the program:
这是程序:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
This is the error:
这是错误:
Exception in thread "main" java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader.run(URLClassLoader.java:372)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
回答by alfasin
The reason you're getting this error is because you didn't save the class into a file called Hello.java
(case-sensitive!)
您收到此错误的原因是您没有将类保存到名为Hello.java
(区分大小写!)的文件中
回答by ankit
This is just problem of intellij IDE.
这只是intellij IDE的问题。
Solution Steps:
解决步骤:
- CtrlShiftAlts-> Preject Setting-> modules tab-> expand
<project_name>
and go to<project_name>_main
- refer Image:
- In Sources tab-> ** click on x symbol**
- CtrlShiftAlts->项目设置->模块选项卡->展开
<project_name>
并转到<project_name>_main
- 参考图片:
- 在 Sources 选项卡中-> ** 点击 x 符号**
Finally build your project.
最后构建你的项目。
Enjoy.
享受。