Hi there, I decided to try learning Java, so I installed some old magazine cover CD software: Visual Cafe 2 and JBuilder. The first thing I discovered was that Java has changed a lot since then, so I bought Bruce Eckel's Thinking in Java and downloaded and installed the Java SDK from www.sun.com. I tried compiling and running the first program from TIJ. It compiled fine, but gave this output when trying to run it: <CONSOLE> F:\JDK\tijcode\c02>java hellodate Exception in thread "main" java.lang.NoClassDefFoundError: hellodate (wrong name: HelloDate) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:486) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111) at java.net.URLClassLoader.defineClass(URLClassLoader.java:248) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:297) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286) at java.lang.ClassLoader.loadClass(ClassLoader.java:253) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) F:\JDK\tijcode\c02> </CONSOLE> Looking at the PATH and CLASSPATH settings, I found settings for Vis Cafe, etc. so I uninstalled them, then uninstalled and reinstalled JDK. I still get this problem. I am running NT, and PATH is set to this: PATH=D:\WINNT\system32;D:\WINNT;D:\PROGRA~1\MICROS~1\Office;f:\jdk\jdk1.3\bin;C:\WIN95;C:\WIN95\COMMAND;C:\DOS6_22 CLASSPATH is not set. I've been hammering at this for hours now. What am I doing wrong? Regards, Jay Ayliff
Joined: Sep 20, 2000
If it gives a NoClassDefFoundError it means you are either spelling the name of the class wrong (remember it is case sensitive) or you need to set you classpath. add the line
and hopefully it will work for you.
Joined: Oct 07, 2000
Case sensitive? I thought it didn't matter 'cos it was a file name! Well I'll be hornswoggled, it works! Much obliged to ya pardner! Jay Ayliff
Joined: Nov 22, 2008
Some times you may have to add .; to the classpath so classpath will look like set classpath=%classpath%;.;f:\jdk\jdk1.3\lib\tools.jar
Joined: Nov 29, 2002
Where abouts do you set the classpath. I am using XP and am compiling using the command prompt. I have defined a ClassPath under the environment variables in the properties of my computer. Also i have tried the line before compiling at the command prompt "set CLASSPATH=C:\jdk1.3.1\bin\" The only way i can compile is to write "java -classpath . HelloDate"
Joined: May 10, 2001
When you set the classpath in your environment variables, did you include the current direcory? For example, my classpath looks like this .;c:\Dev\src;c:\anydirectoryyouneed Chad