Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Main type is missing?

 
Kacey Simeon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind I dont know how to close the post but I fixed it. Thanks for all of the help from everyone who posted.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the exact error? Is it something similar to- main method not found.
The code you have posted is incomplete
Does your code have a- public static void main(String[] args) method?
If yes- that would be the starting point for the program to start executing.
 
Kacey Simeon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Sanaulla wrote:What is the exact error? Is it something similar to- main method not found.
The code you have posted is incomplete
Does your code have a- public static void main(String[] args) method?
If yes- that would be the starting point for the program to start executing.

I posted the first 6 lines of my code. What I imported, the public static void (string args[]) trows IOException
I mean if your saying i need a public static void main (String[] args) as well then why did it work on my other computer?
 
Zachary Pepin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you got the code you pulled that snippet from to run before, I'm impressed. The method there doesn't even have an identifier. That would explain the missing main type thing, but it should be complaining about the fact that there is no identifier on that method.
 
Kacey Simeon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zachary Pepin wrote:If you got the code you pulled that snippet from to run before, I'm impressed. The method there doesn't even have an identifier. That would explain the missing main type thing, but it should be complaining about the fact that there is no identifier on that method.

Sooo.. Your how do i do that? I mean i just came back from Id camp and the word identifier never came up. What is it?
 
Zachary Pepin
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I meant the name for the method.



There should be some kind of name after the "void" and before the "(string[] args)". Perhaps this was intended to be your main method in which case it should look like below.

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that Java is case-sensitive, it should be String with a capital S, not string with a lower-case s:
 
Kacey Simeon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zachary Pepin wrote:Oh, I meant the name for the method.



There should be some kind of name after the "void" and before the "(string[] args)". Perhaps this was intended to be your main method in which case it should look like below.


Thanks alot!
 
Kacey Simeon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zachary Pepin wrote:Oh, I meant the name for the method.



There should be some kind of name after the "void" and before the "(string[] args)". Perhaps this was intended to be your main method in which case it should look like below.


Same question. I was so sure my dumbass mind only made that mistake but it is still not working. D: It still says that a main type is missing.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't just say "It doesn't work". Please don't just say "I got an error".

What you need to to is post the ENTIRE error message the compiler gives you. Those errors are very specific, so if you generalize or paraphrase it, all that meaning is lost. Much of the time, the compiler can even tell you exactly where the error is, down to the line and even character.

Finally, if your code isn't too long, post ALL of it. Granted, 'too long' is a vague term, but if it is only a hundred lines or so, why not post it all? If it is longer, cut out as much as you can that still shows the error and post that.

It is virtually impossible to help you without know what your code really looks like, and what that error message is.

 
Maneesh Godbole
Saloon Keeper
Posts: 11196
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you recompiled (using the javac) the code after you made the changes to your java file?
 
Kacey Simeon
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:Please don't just say "It doesn't work". Please don't just say "I got an error".

What you need to to is post the ENTIRE error message the compiler gives you. Those errors are very specific, so if you generalize or paraphrase it, all that meaning is lost. Much of the time, the compiler can even tell you exactly where the error is, down to the line and even character.

Finally, if your code isn't too long, post ALL of it. Granted, 'too long' is a vague term, but if it is only a hundred lines or so, why not post it all? If it is longer, cut out as much as you can that still shows the error and post that.

It is virtually impossible to help you without know what your code really looks like, and what that error message is.


The error message only read "Selection does not contain a main type." I mean i want to give you more info on the error but there is not much to it. The only true problem is, is that it is saying my public static void main (String[] args) throws IOException is missing which is clearly not. The only other thing that COULD cause a problem is the fact that the highscore system was the first time doing it. I guess Ill post that. *Shrug*
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't go looking in the high score system for errors in the main method.

You are making the mistake of trying to create too much code all at once. You ought to write about 5 lines, compile, execute, and then write another 5 lines.

If you are getting a can't find main method error, then you need to find the main method. Since that sort of error occurs before the high score bit, the high score bit is never reached, and is therefore not relevant. Add the following as the first line of your main method:
System.out.println(123 / 0);
Yes, it looks like nonsense. And we all know it won't work. But when you get the JVM complaining about dividing by 0 and a line number in the main method, you know you have got that far and all the rest of the code has been isolated. Once you have that problem sorted out, getting rid of my extra line will allow you to go back to your whole app.

And please read what people have been saying. They are giving you good advice. Even if you are confusing things with copying errors, or going back to edit old posts, which makes the replies look like nonsense.
Don't alter a post which has been replied to.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kacey Simeon wrote:Never mind I dont know how to close the post but I fixed it. Thanks for all of the help from everyone who posted.

It would be nice if you'd post here what the problem was. One of the things we like about a forum is that problems and solutions are searchable. In the future, it would be great if someone could come here, search for 'main type is missing', find your thread, and see what you did to solve it, as they might be having the exact same problem.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kacey Simeon wrote:Never mind I dont know how to close the post but I fixed it. Thanks for all of the help from everyone who posted.

And also please dont remove the question. People reading this thread would be confused as to why the other people have sent in so many replies when there isnt a question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic