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

Error in running a small program in linux

 
Shashi Bhushan N
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I just compiled a small java program in windows and ran it there it was fine.
The same thing i compiled in linux and got the class file. Afterwords on attempting to run it, it was giving me "ClassNotFoundError".
What could be the reason?
Thankyou and regards.
 
Maarten Vergouwen
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the error states, it cant find what it needs to.
Take a look at your Classpath systemvariable to see if it includes all the locations you need to get to.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps running the Java app with the following statement will resolve the problem.
java -classpath . MyClass
If the program does then run, then as suggested above, it's a CLASSPATH setting issue. If you need help on figuring out how to set the CLASSPATH in Linux, just ask. You might also want to try a quick search of past conversations in the Linux / UNIX forum, as I'm sure others have wondered about the same thing. Note that the search page link is at the top right of the page.
 
sever oon
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, make sure in the transition from one platform to another that the filename of the class file preserved its case. Windows is case agnostic--not case insensitive, because it does preserve case--it just doesn't care about case when matching a filename you're typing.
So, I sometimes find (depending on the means by which it was transferred), Foo.class on Windows ends up being foo.class on linux.
More likely, though, the previous posters nailed your problem. It's probably that . isn't in your classpath, or that you haven't placed the file in a subdirectory structure matching its package, etc.
sev
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic