The Artima Developer Community
Sponsored Link

Java Answers Forum
NoClassDefFoundError....What's Wrong ?

2 replies on 1 page. Most recent reply: Jun 8, 2002 10:16 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Rohit Prakash Khare

Posts: 2
Nickname: rpk2006
Registered: Jun, 2002

NoClassDefFoundError....What's Wrong ? Posted: Jun 7, 2002 5:43 AM
Reply to this message Reply
Advertisement
Hi experts,
Whenever I try to run this program it gives the following error:

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

In my book it is given exactly like this. What's Wrong ?

-------------------------------------------------
class Welcome
{
public static void main(String args[])
{
System.out.println("Welcome to Java");
}
}
------------------------------------------------


hhichijo

Posts: 3
Nickname: hhichijo
Registered: Jun, 2002

Re: NoClassDefFoundError....What's Wrong ? Posted: Jun 8, 2002 9:55 AM
Reply to this message Reply
Assuming that you have compiled the code correctly, the most likely reason for the exception is that you have not set up your classpath correctly. Check documentations about running your first program on the Sun's site.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: NoClassDefFoundError....What' s Wrong ? Posted: Jun 8, 2002 10:16 PM
Reply to this message Reply
My guess is that you are doing this:
   java Welcome[b].java[/b]

or this:
   java Welcome[b].class[/b]

instead of this:
   java Welcome

They did a lot of very clever things with java, but one of the bone-head stupid things about it is the fact that it won't infer the right class name if you add an extension to the file. It won't even give you a useful error message like: "The java command doesn't know that you want to use the class file Welcome.class, even though you specified Welcome.class on the command line, because it was expecting just the class name without a file extension (really, it tried to find a class called 'class' in a package called 'Welcome'), so try typing in 'java Welcome' and things should work fine."

Flat View: This topic has 2 replies on 1 page
Topic: Java Security Question Previous Topic   Next Topic Topic: Problem when adding a null layout JPanel on to JScrollPane

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use