| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 06/02/2006 06:18:55
|
lmr
Newbie
Joined: 06/02/2006 06:09:35
Messages: 3
Offline
|
Have just downloaded JDK 1.5.0_07 on PC with WindowsXP. Program compiles ok but I get the following runtime error:Exception in thread "main" java.lang.No ClassDefFoundError: I think I've tried just about everything under the sun and am running out of time to finish my assignment
This message was edited 1 time. Last update was at 06/02/2006 06:24:15
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 06/02/2006 08:09:00
|
tfecw
Newbie
Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline
|
lmr wrote:Have just downloaded JDK 1.5.0_07 on PC with WindowsXP. Program compiles ok but I get the following runtime error:Exception in thread "main" java.lang.No ClassDefFoundError: I think I've tried just about everything under the sun and am running out of time to finish my assignment
Give this command a shot:
java -cp . (nameOfYourClass)
And let us know how it goes.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 06/02/2006 17:08:55
|
lmr
Newbie
Joined: 06/02/2006 06:09:35
Messages: 3
Offline
|
Gives me - unrecognised option -cp.<classname>. Could not create the Java virtual machine. It seems I'm missing something but I don't know what. I have the java and class files saved on my flash drive (E and Java is loaded on (C . When I view the java files on my flash drive they just look like text files not java files but they are all .java
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 06/02/2006 17:46:30
|
stdunbar
Newbie
![[Avatar]](/images/avatar/a87ff679a2f3e71d9181a67b7542122c.png)
Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline
|
Can you give us a bit more information about your directory structure? Java is very picky that if a class is in a package that it must have the same directory structure as the packing. So if your class is in the package a.b then your class has to be in the directory a/b/YourClassName.class.
|
Thanks for using the forums at hotjoe.com |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 06/02/2006 19:53:36
|
lmr
Newbie
Joined: 06/02/2006 06:09:35
Messages: 3
Offline
|
Have relocated all files to C: drive To give a specific example my assignment "studentEntry" is located as in C:\classwork\studentEntry.class and the java file is C:\classwork\studentEntry.java
The java program is located in C:\program files\java
This message was edited 1 time. Last update was at 06/02/2006 19:56:24
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 06/07/2006 06:57:19
|
nvidura
Newbie
Joined: 06/07/2006 06:45:53
Messages: 1
Offline
|
lmr wrote:Have just downloaded JDK 1.5.0_07 on PC with WindowsXP. Program compiles ok but I get the following runtime error:Exception in thread "main" java.lang.No ClassDefFoundError: I think I've tried just about everything under the sun and am running out of time to finish my assignment
first of all check by typing on cmd prompt (javac) that if it shows u some deffinitions than ur class path is ok. when u execute your class file the only ned to give is your class file name on cmd prompt. like
c:\>java temp (enter)
if found this error in future then u defined the class as public in which u defined ur main func.
so
name ur file same as ur public class file (case is also considered) ur prob is solved. now only thing hv to do is just type temp
This answer must help you.
This message was edited 1 time. Last update was at 06/07/2006 06:58:54
|
Sri Lankan Friends |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 08/08/2006 00:46:36
|
eranga262154
Newbie
Joined: 07/24/2006 00:46:25
Messages: 14
Location: Sri Lanka
Offline
|
stdunbar wrote:Can you give us a bit more information about your directory structure? Java is very picky that if a class is in a package that it must have the same directory structure as the packing. So if your class is in the package a.b then your class has to be in the directory a/b/YourClassName.class.
You mean that this is problem with classpath. When i'm working with Java I set the classpath as follows to the working directory.
D:\java> path=C:\jdk1.4.0\bin\
C: is the java instalation driver and D: is the working directory.
What you think about that.
Is it the case with
Re:Exception in thread "main" java.lang.NoClassDefFoundError - Urgent help required
|
|
|
 |
|
|