*
The moose likes Beginning Java and the fly likes Error in running a small program in linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in running a small program in linux" Watch "Error in running a small program in linux" New topic
Author

Error in running a small program in linux

Shashi Bhushan N
Greenhorn

Joined: Sep 02, 2003
Posts: 12
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

Joined: Jan 12, 2004
Posts: 60
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

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
sever oon
Ranch Hand

Joined: Feb 08, 2004
Posts: 268
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in running a small program in linux