• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Can't run anything

 
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
 
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
 
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
 
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"
 
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
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic