Hi I recently downloaded JMK MAKE to use with "Thinking in Java." It organizes files. If anyone is using it I'd appreciate hearing from you. One of the sample programs from the book won't run. When I compiled the program Assignment.java from > chapter three (c03) of Thinking In Java, a new folder > is automatically created in the directory and named > c03. In this folder is the Assignment.class. This is > the command I use: > c:\j2sdk1.4.0_01\MySourceCode>javac -d > /j2sdk1.4.0_01/MyByteCode Assignment.java > > > When I try to run the program with the command > c:\j2sdk1.4.0_01\MyByteCode>java Assignment, I get the > following error: > > Exception in thread "main" > java.lang.NoClassDefFoundError: Assignment > > or within the folder c03 > > c:\j2sdk1.4.0_01\MyByteCode\c03>java Assignment > > Exception in thread "main" > java.lang.NoClassDefFoundError: Assignment (wrong > name c03/Assignment) > > Do you have any idea why the program cannot find > Assignment.class? Could the JMK MAKE file be > affecting this? > >
maybe you imported some stuff and you need to set the classpath for the VM. Or you defined your code in a package, so it is important to call it like this: java com.test.MyApplication
Joined: Jun 30, 2002
Thanks for the reply. I'm trying that but still getting an "Exception in thread "main" java.lang. NoClassDefFoundError: com/test/Assignment" The system replaces the dots with those forward slashes. P.S. Just returned from a week-long road trip thoughout eastern U.S.A. that's why I'm reply just now.
> c:\j2sdk1.4.0_01\MyByteCode\c03>java Assignment > > Exception in thread "main" > java.lang.NoClassDefFoundError: Assignment (wrong name c03/Assignment)
I see no package or import statements in this code.
Usually when I get an error like this it is because I have the class file in more than one directory. Make sure that the only "Assignment.class" file you have is in the c:\j2sdk1.4.0_01\MyByteCode\c03 directory. Then go to the c:\j2sdk1.4.0_01\MyByteCode\c03 directory and type "java Assignment"
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Jun 30, 2002
Thanks for your combined assistance. I modified the code to include the following: //: c03:Assignment.java package c03; Then I called it with this command statement: C:\j2sdk1.4.0_01\MyByteCode>java c03.Assignment It worked. Appreciate your help. Tina