• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Error message on running the java code from Eclipse

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I installed Eclipse newly on E: drive at my computer and the workspace location is F:\java-exp. the jdk is located at the following path F:\Program Files\Java\jdk1.6.0_02. I am trying to run a new program using Eclipse and am getting the following error "selection does not contain a main type". even .class file is not created in the output folder. can you please help me on this as I am sure that this must be some setup/configuration issue. Also paradon me if I am using a wrong forum for posting this question.

Regards,



 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like what ever class file you are trying to run does not have a

method. It might be that your pressing the Run button when you have the wrong method selected, have no main(...) method, or have the main(...) method declared incorrectly.
 
nitinram agarwal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its a very simple program


public class Hello {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello World");

}

}
 
nitinram agarwal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please can someone help on this
 
author
Posts: 23965
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

There is nothing wrong with the class -- likely an eclipse config error. Moving topic to IDE forum.

Henry
 
nitinram agarwal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone look at it and advice please?
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you create a Java Project or a simple Project?

Is the Hello.java file in a directory identified by Eclipse as a "source directory"? If not, Eclipse will neither compile not run it.

Did you turn off automatic build? Can you build manually?

If you created a Java Project and the Hello.java file is in a source directory, then try adding a package declaration to the class and see if that helps.
 
Honk if you love justice! And honk twice for tiny ads!
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic