File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse annoyance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse annoyance" Watch "Eclipse annoyance" New topic

Eclipse annoyance

jeff mutonho
Ranch Hand

Joined: Apr 30, 2003
Posts: 271
I've created a project in Eclipse , with a few java sources.One of the
classes has and I wish to run this.So I'm doing what I've done many
many times before :
Right click on the class file ---->Select Run ,then a popup appears
I then select "Java Application" under the Configurations list , and
click the "New" button at the bottom , which brings out a tabbed
windows.Under the "Main" tab , my project name correctly appears in
the "Project" field.The "Main Class" field is empty , and a message at
the top of the onfig window saying "Main type not specified".I click
on the Search button in order to get to select the class I want to run
(i.e the main type).A popup appears and the "Matching types" list is
empty.The field to type in the class name is greyed out.
What am I missing?
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
The class probably is missing a proper main method?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

The IDE will scan all resources in the project classpath (with an option for expanded scanning inside jars). All classes that contain this exact declaration will be listed in the selection box:

public static void Main(String[] args)

The names and order of the keywords aren't important, but the method signature must match that statement or the class won't be eligible, because it doesn't contain a valid Main method. And, of course "main" isn't acceptable. Java is case-sensitive, so it's got to be "Main". And, unlike C, the argument declaration and return types must be as indicated.

An IDE is no substitute for an Intelligent Developer.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Originally posted by Tim Holloway:
And, of course "main" isn't acceptable. Java is case-sensitive, so it's got to be "Main".

Doing some C# lately, Tim? It's the other way 'round: "main()" has to be lower-case.

[Jess in Action][AskingGoodQuestions]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Oops. Nope, no C#. Just too many main classes named

Case-sensitive programming languages.
I agree. Here's the link:
subject: Eclipse annoyance
It's not a secret anymore!