• Register
2 votes
19 views

Problem:

Let me thanks to all Kodlogs users first. I found this website very helpful over the internet. I found all the users and their behavior and solutions very helpful.

Anyway, I am trying to learn java and I write my very first java program. Unfortunately, my code is not running. Every time I try to run my program it throws back an error: java editor does not contain a main type

I am attaching my code snippet below:

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

Note: I am using eclipse java as my IDE. Don’t know is it the problem of my coding or the IDE.
Any legitimate solution is appreciated.

12 7 7
15,250 points

1 Answer

2 votes
 
Best answer

Solution:

This problem can occur for a coup;e of reasons. The first one is if your code doesn't have the main function, and the other one is if your source folder isn’t identified as the source folder by the IDE.

However, you have the main function in your program. So, we can amid the first option. The obvious reason is your IDE couldn’t identify the source folder.

Let’s fix it by doing:

  1. Right-click on the project folder -> Properties
  2. Choose 'Java Build Path'
  3. Click on 'Sources' tab on the top
  4. Click on 'Add Folder' on the right panel
  5. Select your folders and apply

Now you are all set to go. Compile your program and run.
Thanks.

13 9 6
94,240 points

Related questions

1 vote
2 answers 84 views
84 views
Problem: Dear all, Right now I’ve imported a maven project into my eclipse IDE and I changed my java path library to work on java 1.7 Suddenly, eclipse started showing an error but I’ve got no errors in my files there. The error is “java compiler level ... Project Problem (Java Version Mismatch) Please tell me how to resolve this error (I want to have my JRE version as 1.7 only).
asked Mar 22 Gavin 15.3k points
1 vote
1 answer 133 views
133 views
Problem: Hello Guys, I am trying to import a Maven project in my Eclipse IDE but the project is not importing properly. It shows an error, source folder is not a java project when I m trying to give it a new call-in it. The problem is literally going over my head ... the problem, as well as have a solution, please speak up. I'm surfing over the internet for an hour but couldn’t fix this yet.
asked Apr 2 Gavin 15.3k points
1 vote
1 answer 12 views
12 views
Problem: Hello guys, I am a novice in the programming world. I&rsquo;ve started learning with the C/C++ language. I&rsquo;ve got a piece of C++ code with two classes. The program is throwing a compile-time error does not name a type I am ... receiveMessage(); vector<Message> *dataMessageList; }; I am looking forward to having a legitimate solution to the problem. Thanks for your kind concern
asked Apr 29 Gavin 15.3k points
0 votes
1 answer 764 views
764 views
Problem : When I run the apache tomcat7.0.56 in Eclipse, I get below error Error: Could not find or load main class org.apache.catalina.startup.Bootstrap How can I fix the above problem?
asked Jan 18 jwilliam 3.9k points