Results 1 to 13 of 13

Thread: Java error

  1. #1
    Kazkar is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Java error

    I made a file using notepad. Saved x.java. CMD>File directory>javac x.java. Two files came to my desktop x.class and x$.class. I typed "java x" in right directory and this error came:

    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: guesscolor (wr
    e: GuessColor)
    at java.lang.ClassLoader.defineClass1(Nativ… Method)
    at java.lang.ClassLoader.defineClass(Unknow… Source)
    at java.security.SecureClassLoader.defineCl… Source)
    at java.net.URLClassLoader.defineClass(Unkn… Source)
    at java.net.URLClassLoader.access$100(Unkno… Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivile… Method)
    at java.net.URLClassLoader.findClass(Unknow… Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadCla… Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoad… Source)
    And when I type " java x.class " it gives me this:

    Java Code:
    Error: Could not find or load main class x.class
    So my question is, how can I fix those errors and make it run properly?

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default Re: Java error

    probably the signature of the main() is wrong. can you show how your main() is declared?

  3. #3
    Kazkar is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Java error

    You mean that?

    Java Code:
     public static void main(String[] args){
            x c = new x();
            c.start();
        }

  4. #4
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default Re: Java error

    A) x is a bad class name. Java classes should be leading cap, and longer than one letter.
    B) guesscolor and GuessColor are not the same class. NoClassDefFoundError is your culprit.
    C) until the program compiles, it will not run with java.exe. Get the compiler errors to go away first. You may want to try an IDE (Eclipse, NetBeans, etc.) which can help you identify missing classes/bad name prior to compile time.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Java error

    Please go through the Forum Rules -- particularly the third paragraph.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Kazkar is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Java error

    I tried to hide the name lol. It's guesscolor class. So how can I fix the problem(s)?

  7. #7
    Kazkar is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Java error

    Come on this is urgent :(

  8. #8
    Kazkar is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Java error

    I'm sorry, I shouldn't bump this much but this is really urgent. It has to be done in 2 hours :( I tried my parents, teacher and yahoo ask but still nothing. Please if you got anything to ask or you know the answer or anything please just post :l

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Java error

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    Kazkar is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Java error

    Quote Originally Posted by DarrylBurke View Post
    Thnx, didn't help atall though. Luckily I got more time now. Its still urgent.

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Java error

    Quote Originally Posted by Kazkar View Post
    Thnx ...
    Didn't you learn anything from the page I linked?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  12. #12
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default Re: Java error

    Once again: guesscolor and GuessColor are NOT the same to the java compiler.

    Using an IDE (Eclipse, NetBeans, etc.) will help you find these. Many IDEs for Java are free to download and use.

  13. #13
    Kazkar is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: Java error

    Theres nothing wrong with source code.. Too late now, thanks for trying -.-

Similar Threads

  1. Replies: 3
    Last Post: 05-08-2012, 05:26 PM
  2. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM

Posting Permissions

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