aspose file tools*
The moose likes Beginning Java and the fly likes Main type is missing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Main type is missing?" Watch "Main type is missing?" New topic
Author

Main type is missing?

Kacey Simeon
Greenhorn

Joined: Jul 30, 2011
Posts: 18
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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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.


Mohamed Sanaulla | My Blog
Kacey Simeon
Greenhorn

Joined: Jul 30, 2011
Posts: 18
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

Joined: Jul 29, 2011
Posts: 5
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

Joined: Jul 30, 2011
Posts: 18
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

Joined: Jul 29, 2011
Posts: 5
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

Joined: Aug 16, 2005
Posts: 14274
    
  21

Note that Java is case-sensitive, it should be String with a capital S, not string with a lower-case s:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Kacey Simeon
Greenhorn

Joined: Jul 30, 2011
Posts: 18
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

Joined: Jul 30, 2011
Posts: 18
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

Joined: Oct 02, 2003
Posts: 11422
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Have you recompiled (using the javac) the code after you made the changes to your java file?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Kacey Simeon
Greenhorn

Joined: Jul 30, 2011
Posts: 18
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

Joined: Oct 13, 2005
Posts: 39436
    
  28
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

Joined: Oct 02, 2003
Posts: 11422
    
  16

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

Joined: Sep 08, 2007
Posts: 3071
    
  33

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Main type is missing?