• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting the ball rolling  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author and jackaroo
Marshal Commander
Posts: 12156
256
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
     
    Ranch Hand
    Posts: 3404
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What about the classpath ? Would you need to include a new directory(ies) ?
    regards
     
    Saloon Keeper
    Posts: 18800
    74
    Android Eclipse IDE Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Craig Thatcher
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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 ]
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!