[fedora-java] Eclipse error when doing a "Run As" in a java project

Jeff Johnston jjohnstn at redhat.com
Tue Dec 4 21:51:44 UTC 2007


Timothy Selivanow wrote:
> I'm seeing issues when trying to do a "Run" or "Run As".  I went
> through the HelloWorld tutorial to make sure I'm not missing anything,
> and at the end of the tutorial when it says:
> 
> To run your application, right-click on your class in the Package
> Explorer and select Run As > Java Application. The Console view should
> appear at the bottom and display the "Hello, world!" output.
> 
> 
> There is only "Open Run Dialog..." when I right click on the class and
> hover on "Run As".  If I go through and add a configuration under "Java
> Application" (and add HelloWorld as the class) or just click the run
> button on the toolbar and choose "Java Application", I get the following
> error:
> 
> Exception in thread "main" java.lang.NoSuchMethodError: main
> Error: A JNI error has occurred, please check your installation and try
> again
> 
> 
> What am I missing?
> 
> 

Timothy,

It appears you do not have a proper main method.  You should have the 
following method in your HelloWorld.java file:

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

You would have gotten this when you created your New Class if you asked 
it to create your main method (there is a click box).

If you right-click on the java file, you will be offered the option to 
run it as a Java Application.  If you rename it to main2, for example, 
you will instead see "Open Run Dialog" offered.  If you try and force 
this to be run via the dialog, you will get the error message you are 
seeing which is entirely expected.

-- Jeff J.
> 
> --Tim
>  _________________________________________________________________________________ 
> /         NEW YORK-- Kraft Foods, Inc. announced today that its board of          \
> | directors unanimously rejected the $11 billion takeover bid by Philip           |
> | Morris and Co. A Kraft spokesman stated in a press conference that the          |
> | offer was rejected because the $90-per-share bid did not reflect the            |
> | true value of the company.                                                      |
> |         Wall Street insiders, however, tell quite a different story.            |
> | Apparently, the Kraft board of directors had all but signed the takeover        |
> | agreement when they learned of Philip Morris' marketing plans for one of        |
> | their major Middle East subsidiaries.  To a person, the board voted to          |
> | reject the bid when they discovered that the tobacco giant intended to          |
> \ reorganize Israeli Cheddar, Ltd., and name the new company Cheeses of Nazareth. /
>  --------------------------------------------------------------------------------- 
>   \
>    \   \
>         \ /\
>         ( )
>       .( o ).
> 
> --
> fedora-devel-java-list mailing list
> fedora-devel-java-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-devel-java-list




More information about the java-devel mailing list