Welcome to Dream.In.Code
Become a Java Expert!

Join 150,194 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,047 people online right now. Registration is fast and FREE... Join Now!




Error: NoClassDefinitionFound

 
Reply to this topicStart new topic

Error: NoClassDefinitionFound, noclassfound error

sandeepb1987
25 Sep, 2008 - 04:10 AM
Post #1

New D.I.C Head
*

Joined: 25 Sep, 2008
Posts: 1

while i am running asimple java proogram it shows a error message like this "exception in thread main java.lang.noclassdeffounderror:add" here add is class name how i can fix this problem help me plz. The same error shows in all codes
User is offlineProfile CardPM
+Quote Post

dineeshd
RE: Error: NoClassDefinitionFound
25 Sep, 2008 - 04:16 AM
Post #2

D.I.C Addict
Group Icon

Joined: 30 Jun, 2008
Posts: 579



Thanked: 16 times
Dream Kudos: 575
My Contributions
Show us your code...
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Error: NoClassDefinitionFound
25 Sep, 2008 - 04:55 AM
Post #3

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
And also please show as the command line you use to start your program if you are launching it from a prompt.
User is offlineProfile CardPM
+Quote Post

bbq
RE: Error: NoClassDefinitionFound
25 Sep, 2008 - 07:46 AM
Post #4

D.I.C Head
Group Icon

Joined: 15 May, 2008
Posts: 200



Thanked: 17 times
Dream Kudos: 50
My Contributions
Generally speaking this error occurs when you save your class with the wrong filename

for example, if you make a class called HelloWorld You must save your file exactly the same as the class name so you would save the file as HelloWorld.java

eg.
java

class HelloWorld
{
public static void main(String[] args)
{
System.out.println("HelloWorld");
}
}


So this if saved as a file would have to be saved exactly as HelloWorld.java so that the filename is the same as the name of the class wink2.gif
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Error: NoClassDefinitionFound
25 Sep, 2008 - 07:49 AM
Post #5

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,319



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Modified topic title to be more descriptive of the problem.
User is offlineProfile CardPM
+Quote Post

johnmalloy
RE: Error: NoClassDefinitionFound
25 Sep, 2008 - 07:50 AM
Post #6

New D.I.C Head
*

Joined: 24 Sep, 2008
Posts: 8



Thanked: 2 times
My Contributions
java

class HelloWorld
{
public static void main(String[] args)
{
System.out.println("HelloWorld");
}
}

The problem is the System.out.println("HelloWorld");
Use this
System.out.print("HelloWorld"):

That should fix it.
Look in the book index and see what the difference is between the two System.out commands.
Hope this helps.
User is offlineProfile CardPM
+Quote Post

pbl
RE: Error: NoClassDefinitionFound
25 Sep, 2008 - 02:27 PM
Post #7

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(johnmalloy @ 25 Sep, 2008 - 08:50 AM) *

java

class HelloWorld
{
public static void main(String[] args)
{
System.out.println("HelloWorld");
}
}

The problem is the System.out.println("HelloWorld");
Use this
System.out.print("HelloWorld"):

That should fix it.
Look in the book index and see what the difference is between the two System.out commands.
Hope this helps.


Sorry John, I'm afraid it has nothing to do.
System.out.println() is a valid method which appends a \n to the end of the String

User is offlineProfile CardPM
+Quote Post

johnmalloy
RE: Error: NoClassDefinitionFound
25 Sep, 2008 - 04:38 PM
Post #8

New D.I.C Head
*

Joined: 24 Sep, 2008
Posts: 8



Thanked: 2 times
My Contributions
QUOTE(pbl @ 25 Sep, 2008 - 03:27 PM) *

QUOTE(johnmalloy @ 25 Sep, 2008 - 08:50 AM) *

java

class HelloWorld
{
public static void main(String[] args)
{
System.out.println("HelloWorld");
}
}

The problem is the System.out.println("HelloWorld");
Use this
System.out.print("HelloWorld"):

That should fix it.
Look in the book index and see what the difference is between the two System.out commands.
Hope this helps.


Sorry John, I'm afraid it has nothing to do.
System.out.println() is a valid method which appends a \n to the end of the String

Stand corrected, thanks 8-)
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:27AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month