This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes No Class DefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "No Class DefFoundError" Watch "No Class DefFoundError" New topic
Author

No Class DefFoundError

Lalit Nagalkar
Ranch Hand

Joined: Aug 22, 2006
Posts: 47
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


SCJP 1.4
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1357
    
  17
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

Joined: Aug 22, 2006
Posts: 47
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

Joined: Nov 03, 2006
Posts: 1357
    
  17
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No Class DefFoundError
 
Similar Threads
Clearing the Screen URGENT !!!!!
Exception
develpoing simple mbean
Getting Exception when the program is executed.
Class.forName error