• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head1stJava - pg 88 - 24 lines of confusion  RSS feed

 
Ioan Sirbu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone.

I am going through the O'Reilly Head First Java. I am trying to do all the exercises provided at the end of the chapters and really gain serious understanding as to what the code is doing rather then typing out and just pluging in different variables.

I'm suffering from a few issues that I seem to be blind to.

I've checked the OReilly site on the errata confirmed,unconfirmed and revised.

I did have the code running however in my effort to see and visualize all the steps it takes I seem to have broken it. I've double checked my code to match what is in the book and can't find the error(s?).

I want to understand why I'm getting an exception that states that main is NoClassDefFoundError?

Please help.

Thank you.

Sincerely,
Ioan C. Sirbu

_____________________

 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that you don't necessarily have a problem with the program itself, but rather with the environment in which you are running it. Basically, you are telling the JVM to run the main method in the Mix4 class, and it is reposnding by telling you that it cannot find the Mix4 class.

What is the environment you are running in? (The directory structure and command used to run the program are good places to start...after that, check the CLASSPATH)
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no problems compiling and running this code as is. Did you save the source with the same name as the public class, that is Mix4.java?
 
Ioan Sirbu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would be really weird because I haven't had this issue with my path or classpath env settings...

-Ioan

_____________

H:\HeadFirstJava\Mix4_88> path
PATH=C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;H:\jdk1.5.0_01\bin

H:\HeadFirstJava\Mix4_88> java -version
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

H:\HeadFirstJava\Mix4_88> javac Mix4.java

H:\HeadFirstJava\Mix4_88> java Mix4.class
Exception in thread "main" java.lang.NoClassDefFoundError: Mix4/class
 
Ioan Sirbu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I deleted and recreated the director(ies) and rebuilt the Mix4.java file from scratch...

It works fine now...

Turns out there was a file open or lock or something somewhere. We can blame Borland and me for having two projects open in JBuilder X....

Thanks guys for getting me and my thinking on on the right track...
[ January 07, 2005: Message edited by: Ioan Sirbu ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!