Results 1 to 4 of 4
  1. #1
    Aman is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Exclamation Could not find the main class: mocha.Decompiler.

    Hello everyone,

    I have a problem with mocha:

    1. I have installed jdk 6u22 and jre 6u22;
    2. I have copyed the myclass.class and mocha.zip to the same folder - c:\myclasses;

    But when I typed "java mocha.Decompiler -v -o myclass.class" in the CMD window with "c:\myclasses>" prompt then pressed "Enter", I got the massage as follow:
    ---------------------------------------------------------------------
    Exception in thread "main" java.lang.NoClassDefFoundError: mocha/Decompiler
    Caused by: java.lang.ClassNotFoundException: mocha.Decompiler
    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)
    Could not find the main class: mocha.Decompiler. Program will exit.

    ------------------------------------------------------------------------

    What's the reason.Could somebody help me ?

    Thanks a lot.
    Last edited by Aman; 12-01-2010 at 04:25 AM. Reason: errors

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

    Default

    thread "main" java.lang.NoClassDefFoundError: mocha/Decompiler

    This means that the java executable could not find mocha.Decompiler on the classpath.

    Things to do/check:

    (1) Make sure you have the mocha classes or jar file in c:\myclasses and not the .zip file. You might have to extract the zip file to get at the classes.

    (2) Specify the classpath on the command line. If the zip contains a jar file like mocha.jar then the command will look something like

    Java Code:
    java -cp mocha.jar mocha.Decompiler -v -o myclass.class

    If the zip has a mocha folder within it then the command will look like

    Java Code:
    java -cp . mocha.Decompiler -v -o myclass.class

    Read the instructions that came with the library, or are available from whereever you got it. You need usage instructions.

    (3) Make sure mocha.Decompiler has a main() method. Or, to put it another way, read the instructions and confirm that this is the class you should be specifying on the command line.

  3. #3
    Aman is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    Thank you, pbrockway.

    With your advices,I checked my steps carefuly, then found the reason.

    I made a low level mistake, I forgot to specify the classpath.

    (Don't laugh , I am a brand-new beginner.....hehe....)

    So, When I specify the classpath like this
    SET CLASSPATH=c:\myclasses;c:\myclasses\mocha.zip
    It works.

    The result is
    C:\myclasses>java mocha.Decompiler
    Usage: java mocha.Decompiler [-v] [-o] <Class1.class> <Class2.class>...
    Thanks again, rockway!
    Best wishes for you!
    Last edited by Aman; 12-01-2010 at 04:02 PM. Reason: Errors

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

    Default

    You're welcome. I'm glad you've got the decompiler running.

Similar Threads

  1. Could Not Find Main Class (again)
    By illjavathat in forum New To Java
    Replies: 25
    Last Post: 11-23-2010, 10:49 AM
  2. Could Not Find Main Class (AGAIN!)
    By illjavathat in forum New To Java
    Replies: 54
    Last Post: 10-22-2010, 04:22 AM
  3. could not find main class?
    By deathnote202 in forum New To Java
    Replies: 6
    Last Post: 05-10-2010, 09:57 PM
  4. Could not find main class - JDK 1.6
    By Syranno in forum New To Java
    Replies: 1
    Last Post: 07-25-2008, 05:07 PM
  5. JVM Could not find main class
    By banduskank in forum Advanced Java
    Replies: 2
    Last Post: 06-24-2008, 09:05 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
  •