Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No Class DefFoundError

 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello every one
I am getting this exception when running any standalone application as simple as HelloWorld
it compiles correctly and I am in the same directory as the class. the class is not in any package

it has started giving this error just recently earlier it never happened. I dont know whats wrong.

Exception in thread "main" java.lang.NoClassDefFoundError: hello

please help
Thanks
lalit
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lalit,

It looks like the kind of error that I get when I misspell the name of the class when running the application. In my case, the two most common causes are

1) I forgot to rename the class that contains the main() method, after renaming the file:



Here, if I compile MyApp.java and then attempt to run the program, I get


If I try to run a program called Test (look at the name of my class), then the program will run successfully, even though I do not have a file called Test.java

2) I misspell the name of the program



The lowercase 'm' in 'myApp' (rather than capital 'M' of 'MyApp') was enough to cause an error.

Katrina
[ March 12, 2007: Message edited by: Katrina Owen ]
 
Lalit Nagalkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Katrina,
Your point is right, but I am not using different file name and different class name as my class is public. its the simplest app
--------
public class HelloWorld
{public static void main(String ar[])
{System.out.println("hello there");
}
}
--------
I am not a novice to Java(to some extent) and have run many other advanced programs, never getting such error.

I am not getting why , I tried reinstalling the jdk1.5.0 and all. But still its happening.. The jboss j2ee server, ant etc runs just fine,

"YES ONE THING" when apache server is run using java command through its settings it too doesnt run, it runs using "jvm".

Pleaze help someone

thanks
lalit
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried changing the parameter to main to



args? It might affect this.



Another issue:

Are you running this from the command line? Or are you trying to run it via an application server? If it is the latter, the server might not be able to see your code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic