简体   繁体   English

在Mac上使用Eclipse的HelloWorld

[英]HelloWorld with Eclipse on Mac

Running the simple HelloWorld.java program below (by clicking run in eclipse) 运行下面的简单HelloWorld.java程序(通过单击eclipse中的run)

public class HelloWorld {
   public static void main (String [] args) {
     System.out.println("Hello World");
   }    
}

after installing the latest version of Eclipse on my mac 10.7.2 yields the following error: 在我的mac 10.7.2上安装最新版本的Eclipse之后,产生以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: 
Caused by: java.lang.ClassNotFoundException: 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

What do i do? 我该怎么办?

Sounds like when you tell it to run you have the wrong class file selected 听起来像当您告诉它运行时,您选择了错误的类文件

Click on the run icon drop down and select Run Configurations, then make sure you have the right class selected for main class. 单击运行图标下拉菜单,然后选择运行配置,然后确保已为主类选择了正确的类。

第一步第二步

使用MacOS随附的默认Java环境为我解决了此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM