Results 1 to 3 of 3
  1. #1
    AaylaSecura is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default [SOLVED] NoClassDefFoundError after decompiling a class file and a minor edit

    Greetings! I extracted a jar file and decompiled one of the classes using jad in order to made a small edit (the original jar was looking to load an image file in the current directory, I replaced the current directory with an environmental variable). I went and recompiled that class. It complained that it cannot find some swt classes, so I downloaded swt.jar for Linux from the Eclipse website and specified the classpath to contain it. It compiled fine and I repacked the jar file. But when I tried to execute it I got:
    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Decorations
            at java.lang.Class.getDeclaredMethods0(Native Method)
            at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
            at java.lang.Class.getMethod0(Class.java:2774)
            at java.lang.Class.getMethod(Class.java:1663)
            at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
            at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
    Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Decorations
            at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    I do not get the same error when I execute the original jar file (that complains that it cannot find the image file unless I put the image in the directory I execute it from). I even tried putting swt.jar in the classpath during execution:
    Java Code:
    java -cp "/path/to/swt.jar:." -jar jar-file.jar
    but got the same error. Any ideas? I'm using IcedteaJDK (OpenJDK) 7 and Linux
    Last edited by AaylaSecura; 05-25-2014 at 12:23 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,812
    Rep Power
    25

    Default Re: NoClassDefFoundError after decompiling a class file and a minor edit

    I don't think the -cp option works with the -jar option.
    Either put your jar on the classpath and name the class file to start in:
    java -cp swt.jar;jar-file.jar YOURCLASSHERE
    or add the swt.jar file to the manifest file's class-path line.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    AaylaSecura is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default Re: NoClassDefFoundError after decompiling a class file and a minor edit

    Thank you! That indeed fixed it.

Similar Threads

  1. Decompiling Java class and breaking cipher
    By rajma in forum Advanced Java
    Replies: 47
    Last Post: 11-22-2013, 06:52 PM
  2. Decompiling Java class and breaking cipher
    By rajma in forum Java Applets
    Replies: 0
    Last Post: 11-16-2013, 09:35 PM
  3. Decompiling java class files
    By ancr2001 in forum New To Java
    Replies: 11
    Last Post: 05-15-2012, 06:59 PM
  4. Replies: 2
    Last Post: 02-22-2012, 11:09 AM
  5. Replies: 2
    Last Post: 10-01-2009, 12:02 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
  •