Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting JDK 1.3 to work!

 
mimi goh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have windows 98 2nd edition, and have installed and set the path for jdk 1.3..i compiled a simple HelloWorld.java file OK, but can't run the HelloWorld.class file!
What am I doing wrong? I got this error message:
C:\J21Work>java HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You get that error when the JVM tries to load a class and it can't find it. Try specifying the classpath when you run it:
java -cp c:\path\to\your\class\file YourClass
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or more specifically in your case:
java -cp C:\J21Work HelloWorld
 
Stanley Tan
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's weird. Shouldn't the current directory be included in the classpath always? I've never had any problems with that. You could do this instead of using -cp:
SET CLASSPATH=%CLASSPATH%;.;
java SomeClass
 
Shubhrajit Chatterjee
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Configure the current directory(.) as a part of the classpath in your autoexec.bat file so that you don't face problems again later.
------------------
Shubhrajit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic