• Register
2 votes
38 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.

15.3k points
reopened by

Please log in or register to answer this question.

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.

94.3k points
selected by

Related questions

0 votes
1 answer 4 views
4 views
Problem: Editor does not contain a main type error.
asked Jul 15 Florina Gulnar 94.9k points
0 votes
1 answer 2 views
2 views
Problem: Editor does not contain a main type eclipse
asked Jul 11 nila 103k points
0 votes
1 answer 2 views
2 views
Problem: Editor does not contain main type in eclipse.
asked Jul 10 Rada Gracelynn 91.8k points
0 votes
1 answer 10 views
10 views
Problem: Editor does not contain a main type in eclipse?
asked Jul 4 Nahil 107k points
0 votes
1 answer 2 views
2 views
Problem: Java selection does not contain main type
asked Jul 11 nila 103k points
0 votes
0 answers 4 views
4 views
Problem: Editor does not contain a main type java.
asked 4 days ago Isac Christiaan 96.6k points
0 votes
0 answers 1 view
1 view
Problem: Java editor does not contain a main type.
asked 4 days ago Isac Christiaan 96.6k points
0 votes
1 answer 37 views
37 views
Is there anything I need to do?
asked Dec 30, 2020 TeamScript 13.5k points
0 votes
1 answer 15 views
15 views
Problem: I am trying to run some java files in a new project. So I make the project, but the files in it and I try to run the main file so my game starts. I get an error that says selection does not contain a main type. I am pretty sure it must work because I ran it a few hours ago at school. How do I get this working? Thank you in advance!
asked Mar 27 ummesalma 29.1k points
0 votes
1 answer 68 views
68 views
How can I resolve this error?
asked Dec 28, 2020 TeamScript 13.5k points