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

Jeff Johnston jjohnstn at redhat.com
Tue Dec 4 22:07:54 UTC 2007


Timothy Selivanow wrote:
> 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?
> 

Yes.  It is looking for that particular main signature.  If you rename 
it don't make it public or static, all of these will cause the same problem.

-- Jeff J.

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




More information about the fedora-devel-java-list mailing list