FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Development Java

 
 
LinkBack Thread Tools
 
Old 12-04-2007, 08:51 PM
Jeff Johnston
 
Default Eclipse error when doing a "Run As" in a java project

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@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-java-list


--
fedora-devel-java-list mailing list
fedora-devel-java-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-java-list
 
Old 12-04-2007, 09:00 PM
Timothy Selivanow
 
Default Eclipse error when doing a "Run As" in a java project

On Tue, 2007-12-04 at 16:51 -0500, Jeff Johnston wrote:
> 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.


I had the method defined, but I had removed "String[] args" thinking
that I didn't need to pass anything to it so I should take it out. Does
this mean that main() needs at least that argument declaration to work
properly?


--Tim
__________________________________________________ ______________________
/ If you float on instinct alone, how can you calculate the buoyancy for
| the computed load? |
-- Christopher Hodder-Williams /
------------------------------------------------------------------------


/
( )
.( o ).

--
fedora-devel-java-list mailing list
fedora-devel-java-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-java-list
 

Thread Tools




All times are GMT. The time now is 11:56 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org