2012-09-18 32 views
0

Possible Duplicate:
Causes of 'java.lang.NoSuchMethodError: main Exception in thread 「main」'方法沒有不工作的Eclipse Java參數

我有一個問題,當我在Eclipse中鍵入下面的代碼,我的錯誤「在線程異常‘主要’java.lang.NoSuchMethodError:主」

public class Hello { 

    public void main() { 

System.out.println("Hello world!"); 
    } 

} 

這是我第一次使用eclipse,我想看看它是什麼樣子。我使用的Ubuntu 12.04與Java-6的OpenJDK-I386

+2

它必須是'公共靜態無效的主要(字符串[] args)' – adatapost

+0

看看這一個:http://stackoverflow.com/questions/5407250/causes-of-java-lang-nosuchmethoderror-main-exception-in-thread-main – RAS

+0

它的工作,謝謝你!奇怪的是,它曾在bluej工作過。 – user1659754

回答

1

您需要使用:

public static void main(String[] args) { 
    System.out.println("Hello world!"); 
} 

或等價:

public static void main(String... args) { 
    System.out.println("Hello world!"); 
} 
相關問題