So, I've finally got my Red Hat 9.0 box up and running along with picking up the latest java book from B&N "Head First Java" (good book but lots of typos). I managed to get the first project to compile and run. But now when I go to run anything , including the first app that worked, I get the following message Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstApp/java any ideas? I've already checked the path and it is in there when I checked.
Hi Craig If it compiled and ran previously when run with the same command line, and now no longer runs, then it implies that you have changed something - possibly installed some different software? Are you running the Sun JDK? or one of the JDKs provided with RedHat? Or ...? Try the following...
type <code>which javac</code>. Tell us the results.
type <code>which java</code>. Tell us the results.
type <code>locate javac | grep "bin/javac$"</code>. Tell us the results.
type <code>locate java | grep "bin/java$"</code>. Tell us the results.
Also, you could post the code you typed here, and we can see if there is anything about the code that would cause it to not run (not likely, since you ran it before). Regards, Andrew
Looks like a straightforward "first-time" problem to me. My default CLASSPATH is blank. The CLASSPATH and PATH are two very different entities, and the Java run-time's in the PATH (or at least, being properly invoked), since otherwise you wouldn't get a Java error message. So you just need a CLASSPATH. I'll bet you typed in: java MyFirstApp.java That's wrong. To compile, it's javac MyFirstApp.java And to run, it's java -classpath . MyFirstApp Unlike the javac program, the java program does not want a file extension, it wants the class name. Note the "dot", which means that the classpath searched included the current directory. You can also set a "CLASSPATH=." statement in your logon script. I prefer not to, since that way every app is required to pull in classes from a specific location and I'm less likely to accidently pull in the wrong copy of something.
Being persecuted doesn't in any way prove your righteousness or your beliefs. Many people get persecuted because they are repugnant or annoying. Or just because they can be.
posted 16 years ago
I haven't tested it yet but I think Tim's got the answer. When trying to execute I envoke the jvm by typing in java MyFirstApp.class :roll: Thank you for the help. [ July 11, 2003: Message edited by: Craig Thatcher ]
You can't have everything. Where would you put it?