Results 1 to 8 of 8
- 11-02-2010, 11:17 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
Could not find the main class, program will exit
Hi everyone, I'm new to this forum and I hope I'm writing in the right board.
I'm working on eclipse 3.5.2 on a Ubuntu VM.
I've been debugging my program for a while now and never had any problem compiling, until yesterday when after just uncommenting a line i got this error while trying to compile:
Exception in thread "main" java.lang.NoClassDefFoundError: Huffman/Main
Caused by: java.lang.ClassNotFoundException: Huffman.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
Could not find the main class: Huffman.Main. Program will exit.
I undoed (oh dear.. it's a regular verb.. isn't it?) the typing thing but did anything.
Thanks a lot in advance for any help.
- 11-02-2010, 11:41 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What's your class name and the file name that you've save as *.java ?
- 11-02-2010, 01:33 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
- 11-02-2010, 01:58 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
That's not a compile time error, that's a runtime error.
- 11-03-2010, 06:25 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Mainly the error 'Exception in thread "main" java.lang.NoClassDefFoundError' means that the class which you are trying to run (not compile) has not found in the classpath.
To solve that problem you can add the class file into the classpath. Are you using any external jar files in your code?
Did you change anything in your classpath?
- 11-03-2010, 06:30 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Some of the compilers doing messy things with the class name and the physical file name. I might ask what's your OS with that question actually, because that messy things happen with some of the Linux version. You can compile a class with two different names. So in that case sometime the *.class file is fail to load.
- 11-03-2010, 06:35 AM #7
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,543
- Rep Power
- 11
That's a slightly nonstandard name. Make sure that you don't mean to run huffman.Main
(since you ask, no, it's irregular: "undid")
- 11-03-2010, 06:51 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Then if something like happen, Eclipse should take the responsibility.
Similar Threads
-
Could not find main class: Jframe. Program will exit.
By egbert95 in forum New To JavaReplies: 4Last Post: 07-29-2010, 02:53 PM -
Could not find main class: Jframe. Program will exit.
By egbert95 in forum Advanced JavaReplies: 8Last Post: 07-29-2010, 02:53 PM -
Could not find the main class, program will exit.
By aryubi in forum New To JavaReplies: 39Last Post: 02-19-2010, 10:02 AM -
Could not find the main class. Program will exit.
By XSROSSITER in forum New To JavaReplies: 0Last Post: 01-30-2010, 04:17 AM -
Could not find the main class. Program will exit.
By Carrier in forum New To JavaReplies: 1Last Post: 04-22-2009, 02:27 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks