954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Editor does NOT contain a main type!!

Hello everyone,

I have a book called "Java Genesis" and it has some files such as packages, projects and hints to enhance learning. So, I have set up a file structure in Eclipse and it shows that there are errors and warnings. When I tried running a Java Application using these files, a major message came up "Editor does not contain a main type". I went through the code and there was

public static void main (String [] args) {

Your help is greatly appreciated and Thanks in advance.

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

Well, if Eclipse "shows that there are errors and warnings" then that class is probably not being compiled and so the project does not contain an executable main class. Fix the "errors and warnings", first.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Click the Src package u have made, i think you must clicked some library and running the application....

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

I clicked on SRC then imported the packages I wanted to run with their accompanying files that support them.


@ Masijade, These packages and projects are from a book. Therefore, they are not written for readers to complete them; they're meant to help readers understand how an app works and play around with the code.

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

it will be very easy for us if u take two or three snapshot of your screen and load here.............

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 
@ Masijade, These packages and projects are from a book. Therefore, they are not written for readers to complete them; they're meant to help readers understand how an app works and play around with the code.

Okay? And? How does that change anything I said? If it doesn't compile it is not a main class. It is anattempt at a main class, but until it compiles there is nothing for Eclipse to execute.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

It is strange that eclipse doesn't find any code to execute. How do you think I can possibly fix the issue?

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

Please post pictures..... I already told u , no body guess what the problem is.

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

well .. just posting

public static void main(String[] args){

says nothing. for all we know, this main method is declared within another method.
so, show the error message (stacktrace, ...) you get, and post some code in which we can see something.

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 
It is strange that eclipse doesn't find any code to execute. How do you think I can possibly fix the issue?

You said that Eclipse "shows errors". Well, how do you propose that Eclipse execute anything that isn't compiled? This is not a scripting language, you know. As I said,fix those errors.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Are u sure ur java file is in src folder ??

murali_quest
Newbie Poster
14 posts since Jul 2011
Reputation Points: 5
Solved Threads: 3
 

they are supposed to be in the src folder ,but when I imported the files, the child files got into their parent folder (well, they were in their parent folder)if this makes sense.

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

I remember having a similar problem, it was saying couldn't find the main, but it was there... I think I solved it just by refreshing the src folder in eclipse, not sure anyway. And I don't know why it said that in the first place

a.oprea
Junior Poster in Training
52 posts since Jul 2011
Reputation Points: 10
Solved Threads: 3
 

These are the print-screen images as requested before and hopefully are illustrating well to you guys. Looking forward to getting a solution to this problem from you all. Thanks in advance.


cheers,

Attachments 1.jpg 59KB 2.jpg 44.15KB 3.jpg 34.43KB
rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

You have 689 uncorrected compile-time errors. Yet you say
It is strange that eclipse doesn't find any code to execute. How do you think I can possibly fix the issue?
There won't be any code to execute until the compiler generates some. The compiler won't compile your code until you fix the errors. Start with the first error and keep fixing them until they are all fixed. Then you will get some code to execute.

ps: Such a large number of errors suggests that you have problems with your project setup, eg incorrect path(s) - but the detailed messages will spell it out for you.

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

Bear in mind that I'm still new to Java language..

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 
Bear in mind that I'm still new to Java language..


That may be so, but Java and Eclipse work the same way regardless of your experience

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

I've already told you that until it compiles there is nothing to execute.

And, as far as being new goes, then you need to start with something simpler, such as the official tutorials.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This is not helping at all, guys. I don't want to change anything written in those classes because they seem to be built on the top of each other.

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

I never ever down-voted on all forums where I member of, you are 1st. candidate during this month, are you thinking about that all posters in this thread just wasted her/his time for your ...., everything is wrong

mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You