Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't run anything

 
Jay Ayliff
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Noah Carroll
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

set classpath=%classpath%;f:\jdk\jdk1.3\lib\tools.jar

and hopefully it will work for you.
 
Jay Ayliff
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
tom berg
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
 
Chad McGowan
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic