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

Join 149,493 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,361 people online right now. Registration is fast and FREE... Join Now!




Exception in thread "main" java.lang.NoClassDefFoundError

 
Reply to this topicStart new topic

Exception in thread "main" java.lang.NoClassDefFoundError

ciffycyclops
10 Mar, 2007 - 06:44 AM
Post #1

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 8


My Contributions
hello...
in this case my situation is quite different from the others who have faced the same problem and asked for help in this forum....
i have all my java files in the D:\SNMP folder
in this folder i created a subfolder (lib) to store the SNMP4J.jar file...
so i can use it for my project...
i compiled this file by the following command...
javac -classpath ./classes/;./lib/SNMP4J.jar Testsnmp.java
it compiled succesfully....
now i run this program by....
java -classpath ./classes/;./lib/SNMP4J.jar Testsnmp
now it generates the NOClassDefFound error...

So i thought there must be some problem in my JDK...
so i devoloped a simple hello world program..in the same folder..
and it runs succesfully
[javac Hello.java
java Hello]
Now i used Winrar to extract the jar file.(which i certeinly dont like to do)
and placed the org folder in the SNMP folder...and compile with javac and it runs succesfully by "java Testsnmp" command...
Now the problem is i am using another java package which also have org folder...so i cant have 2 org folder in my project folder(SNMP)....
now how can i run the program without unpacking the jar file...
help me out of it....
sam
User is offlineProfile CardPM
+Quote Post

rpjd
RE: Exception In Thread "main" Java.lang.NoClassDefFoundError
21 Mar, 2007 - 12:13 PM
Post #2

D.I.C Head
**

Joined: 8 Mar, 2007
Posts: 85


My Contributions
I have just re-installed jdk1.6.0 and jakarta tomcat5.0.28 for the umteenth time. I am trying to verify the jdk installation in or to be able to run .java, .jsp files on tomcat. I have added the classpath for JAVA_HOME=c:\Program Files\Java\jdk1.6.0. I saved the java file HelloWorld into a folder called Java on c:\, so c:\Java is the file path.
When I ran javac c:\Java\HelloWorld.java, all seemed ok, no error messages. But when I executed
java c:\Javac\HelloWorld.java I got the error message
Exception in thread "main" java.lang.NoClassDefFoundError c:\Java|helloWorld/class

can anyone advise what I might be doing wrong.

RPJD smile.gif
User is offlineProfile CardPM
+Quote Post

rpjd
RE: Exception In Thread "main" Java.lang.NoClassDefFoundError
22 Mar, 2007 - 03:44 AM
Post #3

D.I.C Head
**

Joined: 8 Mar, 2007
Posts: 85


My Contributions
QUOTE(rpjd @ 21 Mar, 2007 - 01:13 PM) *

I have just re-installed jdk1.6.0 and jakarta tomcat5.0.28 for the umteenth time. I am trying to verify the jdk installation in or to be able to run .java, .jsp files on tomcat. I have added the classpath for JAVA_HOME=c:\Program Files\Java\jdk1.6.0. I saved the java file HelloWorld into a folder called Java on c:\, so c:\Java is the file path.
When I ran javac c:\Java\HelloWorld.java, all seemed ok, no error messages. But when I executed
java c:\Javac\HelloWorld.java I got the error message
Exception in thread "main" java.lang.NoClassDefFoundError c:\Java|helloWorld/class

can anyone advise what I might be doing wrong.

RPJD smile.gif


Deleted jdk1.6.0 and installed j2sdk1.4.2_13 instead. from my HelloWorld dir I ran
java -classpath . HelloWorld
this gave me "HelloWorld"
from my JAVA_HOME dir I ran
javac c:\ProjectFolderName\HelloWorld.java
this compiled ok
then ran
java c:\ProjectFolderName\HelloWorld.java
and got
Exception in thread "main" java.lang.NoClassDefFoundError.

Can someone please explain?

RPJD smile.gif
User is offlineProfile CardPM
+Quote Post

Israel
RE: Exception In Thread "main" Java.lang.NoClassDefFoundError
22 Mar, 2007 - 06:51 AM
Post #4

D.I.C Addict
Group Icon

Joined: 21 Nov, 2004
Posts: 626


Dream Kudos: 175
My Contributions
Why don't you post the code you are using (Not the commands you are using to compile) and see if we can help. biggrin.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 05:53PM

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