Results 1 to 18 of 18
Thread: NoClassDefFoundError
- 02-03-2012, 12:52 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 8
- Rep Power
- 0
NoClassDefFoundError
public class HelloWorld {
public static void main (String[] args){
System.out.print("Hello World!");
}
}
-------------------------------------------------------
This is my code but when i run it, I get this:
java.lang.NoClassDefFoundError: HelloWorld/java
Caused by: java.lang.ClassNotFoundException: HelloWorld.java
at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
Could not find the main class: HelloWorld.java. Program will exit.
Exception in thread "main"
Process completed.
Please HELP!! I really need to fix this..
- 02-03-2012, 12:59 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,403
- Blog Entries
- 7
- Rep Power
- 17
Re: NoClassDefFoundError
You haven't compiled your sources yet and you are trying to run your HelloWorld.java source file.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-03-2012, 01:22 PM #3
Re: NoClassDefFoundError
You left off the command that you issued to get the error message.
You must have used the java command instead of the javac command.
See:"Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)
- 02-04-2012, 02:29 PM #4
Member
- Join Date
- Feb 2012
- Posts
- 8
- Rep Power
- 0
Re: NoClassDefFoundError
thankz for ur comment and i appreciated it...
im using JCreator Pro and I'm sure that not the problem...
I think the classpath or watever.. but i set my classpath to the JDK/bin
- 02-04-2012, 02:34 PM #5
Re: NoClassDefFoundError
That is where the path should point, not the classpath. The bin folder contains .exe files and the path is used by the OS to find them.i set my classpath to the JDK/bin
The classpath is used to find the definition of class by javac.exe and java.exe
Did you compile your source file and create a .class file?
You need to get advice on how to use your IDE. There is a part of this forum for IDEs. Try asking about your problem there.
- 02-04-2012, 02:47 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,403
- Blog Entries
- 7
- Rep Power
- 17
Re: NoClassDefFoundError
Have you compiled your class? Your inital attempt clearly showed that you were trying to run a .java file; .java files contain your source code and cannot be run. You need to compile your source file and produce a .class file; .class files can be run. Read a tutorial on the basics before you are trying to do something.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-04-2012, 02:57 PM #7
Member
- Join Date
- Feb 2012
- Posts
- 8
- Rep Power
- 0
Re: NoClassDefFoundError
yeah... there's a .class file produced...
this problem started when i used the prompt for main method from CONFIGURE>OPTIONS>JDK TOOLS>DEFAULT>EDIT>PARAMETER
- 02-04-2012, 03:12 PM #8
Re: NoClassDefFoundError
There is a part of this forum for IDEs. Try asking about your problem there.
- 02-05-2012, 03:01 AM #9
Member
- Join Date
- Feb 2012
- Posts
- 8
- Rep Power
- 0
NoClassDefFoundError
public class HelloWorld {
public static void main (String[] args){
System.out.print("Hello World!");
}
}
-------------------------------------------------------
This is my code but when i run it, I get this:
java.lang.NoClassDefFoundError: HelloWorld/java
Caused by: java.lang.ClassNotFoundException: HelloWorld.java
at java.net.URLClassLoader$1.run(URLClassLoader.java: 202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 48)
Could not find the main class: HelloWorld.java. Program will exit.
Exception in thread "main"
Process completed.
Please HELP!! I really need to fix this..
- 02-05-2012, 04:05 AM #10
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,606
- Rep Power
- 5
Re: NoClassDefFoundError
HelloWorld.java is not a class file, it is a source file. Did you compile? How are you trying to run the program?
Suggested reading: Lesson: The "Hello World!" Application (The Java™ Tutorials > Getting Started)
- 02-05-2012, 07:04 AM #11
Member
- Join Date
- Feb 2012
- Posts
- 8
- Rep Power
- 0
Re: NoClassDefFoundError
yeah i compied it... this problem started when i used the "prompt for main method" from
CONFIGURE>OPTIONS>JDK TOOL>PARAMTERS
- 02-05-2012, 07:09 AM #12
Member
- Join Date
- Feb 2012
- Posts
- 8
- Rep Power
- 0
Re: NoClassDefFoundError
i did but no one's helping... I'm doomed T_T
- 02-05-2012, 06:00 PM #13
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,606
- Rep Power
- 5
Re: NoClassDefFoundError
Please don't violate forum rules and double post:
NoClassDefFoundError
- 02-05-2012, 06:01 PM #14
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,606
- Rep Power
- 5
Re: NoClassDefFoundError
Please don't violate forum rules and double post
NoClassDefFoundError
That's a great way to thank those that are trying to helpi did but no one's helping... I'm doomed T_T
-
Re: NoClassDefFoundError
I can't say that I blame him as he was suggested to do this by a moderator. Though for my money, I'd just as soon move this over to the IDE section myself, and in fact I think that I'm going to do just that.
Edit: instead, I just merged threads. This may be a little confusing...
Last edited by Fubarable; 02-05-2012 at 06:17 PM.
- 02-05-2012, 07:32 PM #16
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,606
- Rep Power
- 5
- 02-06-2012, 12:36 AM #17
Member
- Join Date
- Feb 2012
- Posts
- 8
- Rep Power
- 0
Re: NoClassDefFoundError
im really sorry... can u advice me what to do in my problem?? i cant start my chat project if i cant solve this... plz i really need some advice...
- 02-06-2012, 12:42 AM #18
Similar Threads
-
NoClassDefFoundError
By PeDz in forum New To JavaReplies: 10Last Post: 02-05-2012, 06:14 PM -
NoClassDefFoundError
By PeDz in forum Advanced JavaReplies: 1Last Post: 02-04-2012, 02:44 PM -
NoClassDefFoundError
By sriram56 in forum IntelliJ IDEAReplies: 0Last Post: 11-26-2011, 03:04 AM -
NoClassDefFoundError
By bmeu in forum JDBCReplies: 1Last Post: 10-30-2010, 08:08 PM -
NoClassDefFoundError
By Josisco in forum JDBCReplies: 2Last Post: 10-30-2010, 08:07 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks