File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Weird: NoClassDefFoundError: Hello Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Weird: NoClassDefFoundError: Hello" Watch "Weird: NoClassDefFoundError: Hello" New topic
Author

Weird: NoClassDefFoundError: Hello

Mark Lau
Ranch Hand

Joined: Dec 15, 2001
Posts: 120
This is really really weird. I have no clue
what has happened to my system.
Look the following. Isn't it funny?
You see, the little program Hello.java has
no problem at all. And this is strangely
proved if I run this program by clicking
on the execute button from JCreator Pro.
It runs pretty well that way.
But if I run it from the DOS Window. I have
the weird exception
java.lang.NoClassDefFoundError: Hello
What might be the problem? If the JVM is
damaged, then it should not have run from
JCreator Pro, right?
The problem persists regardless of which
java.exe I run, be it the one under JAVA_HOME\bin
or the one under C:\WINNT\system32.
Any explanation please? Thank you!
*** Start of the funny java ****
C:\Java>type Hello.java
public class Hello
{ public static void main(String [] args)
{ System.out.println("Hello, world!");
}
}
C:\Java>javac Hello.java
C:\Java>java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
C:\Java>java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
C:\Java>
**** End of the funny java ****
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1863
try running,
java -cp .;%CLASSPATH% Hello
and see if that works...
regards
maulin.


1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You apparently have your classpath set up just fine for your IDE (JCreator) but do NOT have it set up outside the IDE.
You can invoke the program naming the classpath to use (as shown above) or just set your classpath on your machine.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
IntelliJ Java IDE
 
subject: Weird: NoClassDefFoundError: Hello
 
Threads others viewed
Assertions ?
NoClassDefFoundError
Getting the correct date
Resolving most specific method
NoClassDefFoundError
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture