This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
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