Results 1 to 8 of 8
  1. #1
    grottesco is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default 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.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    grottesco is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    What's your class name and the file name that you've save as *.java ?
    It's an eleven classes project, every class has class name equal to file name.
    Or maybe i misunderstood waht you were asking.. I'm pretty noob with both java and eclipse sorry =)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    That's not a compile time error, that's a runtime error.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    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?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by grottesco View Post
    It's an eleven classes project, every class has class name equal to file name.
    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.

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

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

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 4
    Last Post: 07-29-2010, 02:53 PM
  2. Could not find main class: Jframe. Program will exit.
    By egbert95 in forum Advanced Java
    Replies: 8
    Last Post: 07-29-2010, 02:53 PM
  3. Could not find the main class, program will exit.
    By aryubi in forum New To Java
    Replies: 39
    Last Post: 02-19-2010, 10:02 AM
  4. Could not find the main class. Program will exit.
    By XSROSSITER in forum New To Java
    Replies: 0
    Last Post: 01-30-2010, 04:17 AM
  5. Could not find the main class. Program will exit.
    By Carrier in forum New To Java
    Replies: 1
    Last Post: 04-22-2009, 02:27 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •