• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundEroor

 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i've the following class:
public class Test{
public static void main(String[] args){
System.out.println("Hello World!");
}
}
compiles fine when compiled as following:
javac Test.java
and creates a Test.class
but when done as follows:
java Test
gives me following:
Exception in thread "main" java.lang.NoClassDefFoundError: Test
what does it mean? could anyone please point it out? thanks.
himal
 
Haakon Lind
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, what a great forum about java I found, I`ll settle in here for some years.
Ok, Himal.
From beginner to beginner I think you just missed the:
import javax.swing.* ;
bit, must allways have that class you know.
 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haakon,
i don't see any reason why do i need
import javax.swing.* ;

coz i am not using any swing components at all.
if that's what caused my problem, it would not get compiled in the first place and create the "Test.class" so i don't think what you suggested is a valid cause. however, thanks for the reply.
himal
 
Jeelani Sk
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is absolutely no problem with the code.
The only reason is you may be running the 'java' command from a different directory. so either run it from the directory where the Test.class file resides, or make an entry of its path in the system class path to run it from any where.
Jeelani
[ September 18, 2002: Message edited by: Jeelani Sk ]
 
Haakon Lind
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry , nothing wrong with your code anyway, works fine on my pc.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like a classpath problem...
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Himal,
Trying adding the current directory "." to your classpath as JVM looks for class files in the CLASSPATH.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic