java - Java中的Hello World抛出错误

标签 java intellij-idea

关闭。这个问题需要debugging details .它目前不接受答案。












想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。

6年前关闭。




Improve this question




据我了解,IntelliJ 正试图从我首先创建的测试文件中运行程序。
我怎样才能解决这个问题?

我只是想运行一段简单的代码来感受一下Java。我不确定这个错误是什么意思

> Exception in thread "main" java.lang.ClassNotFoundException: Test     at
> java.net.URLClassLoader.findClass(URLClassLoader.java:381)    at
> java.lang.ClassLoader.loadClass(ClassLoader.java:424)     at
> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)     at
> java.lang.ClassLoader.loadClass(ClassLoader.java:357)     at
> java.lang.Class.forName0(Native Method)   at
> java.lang.Class.forName(Class.java:264)   at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

这是我的代码
public class Age {
    public static void main(String[] args){
        System.out.println("Hey Hey");
    }
}

最佳答案

右键单击然后运行 ​​Age.main()。使用this screenshot from building and running java application

enter image description here

另请注意:

The public class name should be the name of the source file as well which should be appended by .java at the end. For example : The class name is . public class Employee{} Then the source file should be as Employee.java.

关于java - Java中的Hello World抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29937293/

相关文章:

java - 如何在 Jupyter Notebook 内的 conda 环境中使用特定的 Java 版本

java - 通过url读取json

java - FreeMarker 和 OSGI

java - 我的返回类型应该是正确的,但 Intelli-J 说它是错误的?需要 ArrayList<ArrayList<Card>>,已找到 boolean 值

intellij-idea - IntelliJ如何放大/缩小

java - 游戏状态黑屏

java - 'this' 关键字指的是哪个当前类对象?

java - Intellij 在 jar 文件中包含 src 文件

java - 如何在 Ubuntu 15.04 上安装 Intellij?

intellij-idea - IntelliJ IDEA : Generate list of TODOs with Todo-text and according file