• Post Reply Bookmark Topic Watch Topic
  • New Topic

No Main Class Found?  RSS feed

 
Alex Hayes
Greenhorn
Posts: 7
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever I try to write a file to the disk and then load it within the same Class (if it is even possible) It gives me an error: Could not find the main class: score.Score. Program will exit. I have tried this with 2 different classes and it works fine? Please tell me what I am doing wrong, and if you can, why that error is appearing. Code:
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code compiles and runs fine for me. How exactly are you running it? The command should be "java score.Score", and the class file should be in a subdirectory called "score".
 
Alex Hayes
Greenhorn
Posts: 7
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:The code compiles and runs fine for me. How exactly are you running it? The command should be "java score.Score", and the class file should be in a subdirectory called "score".


I use Eclipse IDE to run/create programs.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then it's likely an Eclipse issue, as the code itself works fine. I generally advise people to start out without an IDE, as that introduces another layer of complexity that can be hard to make sense of in the beginning.
 
Alex Hayes
Greenhorn
Posts: 7
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Then it's likely an Eclipse issue, as the code itself works fine. I generally advise people to start out without an IDE, as that introduces another layer of complexity that can be hard to make sense of in the beginning.


Okay. So the code is okay, but it's the IDE that has a bug?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's unlikely to have bug in such a basic operation; more likely that you're not using it correctly.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you move the class after running it the first time? Change the package, for instance?

You can probably fix the problem by creating a new project and moving your source code there.
 
Ron McLeod
Bartender
Posts: 1603
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Hayes wrote:I use Eclipse IDE to run/create programs.

How exactly are you running the code from Eclipse?

From the menu bar, when you click on Run, then Run Configurations..., do you see score.Score as the Main class?
 
Alex Hayes
Greenhorn
Posts: 7
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ron McLeod wrote:
Alex Hayes wrote:I use Eclipse IDE to run/create programs.

How exactly are you running the code from Eclipse?

From the menu bar, when you click on Run, then Run Configurations..., do you see score.Score as the Main class?



AH, I have found the problem. I am using JRE 1.6 and the project is required to have 1.7. Thanks for the help.
 
Campbell Ritchie
Marshal
Posts: 56592
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That may be a problem, but it shouildn't produce the Exception you are suffering. It would produce a different Exception.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!