3 Replies - 5061 Views - Last Post: 22 March 2007 - 07:51 AM Rate Topic: -----

#1 ciffycyclops  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 22-February 07

Exception in thread "main" java.lang.NoClassDefFoundError

Post icon  Posted 10 March 2007 - 07:44 AM

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

Is This A Good Question/Topic? 0
  • +

Replies To: Exception in thread "main" java.lang.NoClassDefFoundError

#2 rpjd  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 08-March 07

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

Posted 21 March 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 :)
Was This Post Helpful? 0
  • +
  • -

#3 rpjd  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 88
  • Joined: 08-March 07

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

Posted 22 March 2007 - 04:44 AM

View Postrpjd, on 21 Mar, 2007 - 01:13 PM, said:

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 :)


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 :)
Was This Post Helpful? 0
  • +
  • -

#4 Israel  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 7
  • View blog
  • Posts: 818
  • Joined: 22-November 04

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

Posted 22 March 2007 - 07:51 AM

Why don't you post the code you are using (Not the commands you are using to compile) and see if we can help. :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1