Results 1 to 5 of 5
- 07-23-2011, 09:27 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 2
- Rep Power
- 0
Jave Code Error : "main" java.lang.NoClassDefFound
Plz have a look at the code snippet at Learn Java by Examples - How do I generate UUID / GUID?
I am new to Java and need to run the UUID code snippet kept at above given link.
Heres what i have done
1.Installed jdk1.5.0_22
2.Copied the code snippet into a file named RandomStringUUID.java and kept in C:\test
3. Set the following user variables to
CLASSPATH = C:\Program Files\Java\jdk1.5.0_22\lib
JAVA_HOME = C:\Program Files\Java\jdk1.5.0_22\bin
path = %path%;C:\Program Files\Java\jdk1.5.0_22\bin;
4. From command prompt
C:\Test>javac RandomStringUUID.java
RandomStringUUID.class created
5.From command prompt
java RandomStringUUID
i am getting the error
Exception in thread "main" java.lang.NoClassDefFoundError: RandomStringUUID
Can someone please help??
-
Don't set the CLASSPATH environment variable. Instead, what if you call java with the class path parameter:
Java Code:c:\Test>java -cp . RandomStringUUID
- 07-23-2011, 09:39 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Look at the first line of the source code of that class: it is in a package and you should use that when you try to run the compiled version of that class. Also, read your text book on packages and how to use them before you copy code, compile it and try to run it.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-24-2011, 08:24 AM #4
Member
- Join Date
- Jul 2011
- Posts
- 2
- Rep Power
- 0
I removed the CLASSPATH environment variable
Ran c:\Test>java -cp . RandomStringUUID
And i got this error
Exception in thread "main" java.lang.NoClassDefFoundError: RandomStringUUID (wrong name: org/kodejava/example/util/RandomStringUUID)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
- 07-24-2011, 08:52 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Need Help With Code Error Exception in thread "main" java.lang.NullPointerException
By bwilson0117 in forum New To JavaReplies: 10Last Post: 07-20-2011, 02:11 PM -
Question about error "Exception in thread "main" java.lang.NoSuchMethodError: main
By ferdzz in forum New To JavaReplies: 5Last Post: 06-22-2010, 03:51 PM -
Runtime error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
By shantimudigonda in forum New To JavaReplies: 1Last Post: 11-20-2009, 07:58 PM -
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:10 AM -
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By romina in forum New To JavaReplies: 1Last Post: 07-25-2007, 10:55 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks