Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I've Isolated My Problem Down To This

 
Gary Farms
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I run any Java program in my c:\java, I get the NoSuchMethodError for main. Somehow, main is not getting recognized at run-time.
However, if I copy my Gary.java source program to c:\java\com\gfarms\geometry and add the following statement
at the top of the file:
package com.gfarms.geometry; then compile Gary.java in c:\java\com\gfarms\geometry and run it by saying:
java com.gfarms.geometry.Gary it runs!!
 
Junilu Lacar
Bartender
Posts: 7483
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gary,
Check your CLASSPATH environment variable and make sure you have "." (the current directory) listed in it, as in ".;c:\java" . I think I had the same problem once and that was the cause.

[This message has been edited by JUNILU LACAR (edited June 20, 2001).]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lay you odds that there is another Gary.class out there that does not have a main that is getting picked up from the classpath. When you don't SPECIFICALLY say which class file to run by using the package, the OTHER one gets run and you get an error.
 
Junilu Lacar
Bartender
Posts: 7483
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could be right Cindy, maybe the error I got before was a "class not found" error
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic