Question

I chose ProGuard and here's the options I configured it with:

Shrinking

Options:

  • Shrink

Keep:

  • Applications
  • Applets

Also keep:

  • Enumerations
  • Database drivers
  • Swing UI L&F

Obfuscation

Options:

  • Obfuscate (duh! :P)
  • Overload aggressively
  • Use unique class member names
  • Use mixed-casee class names
  • Flatten package hierarchy
  • Repackage classes

Keep names:

  • native method names
  • .class method names

Optimization

Options:

  • Optimize
  • Merge interfaces aggressively

Remove:

  • [All boxes checked]

Information

Preverifiaction and targeting:

  • Preverify

Consistency and correctness:

  • Note potential mistakes in the configuration
  • Warn about possibly errornous input
  • Skip non-public library class members

and when I take the jar and put it as:

I get this applet error upon launch:

    java.lang.RuntimeException: java.lang.NoClassDefFoundError: b
        at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
        at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NoClassDefFoundError: b
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getConstructor0(Unknown Source)
        at java.lang.Class.newInstance0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: b
        at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 14 more
    Caused by: java.io.IOException: open HTTP connection failed:http://mystikrpg.com/b.class
        at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
        at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
        at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        ... 17 more
    Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: b

Here is what is INSIDE the jar file BEFORE the obfuscation clientOffline.jar:

line_tile/
META-INF/

and here is what that jar file is AFTER the obfuscation to newOne.jar:

line_tile/
META-INF/
weapon/
me.gif
a.class
b.class

I hope this is good enough to help me solve this. What am I doing wrong?

Was it helpful?

Solution

I guess that b.class is generated from the GamePanel inner class. So there can be a problem with inner classes. Here at Stackoverflow Tom mentioned that he could not obfuscate inner classes correctly. The suggestion there also applies here: try to obfuscate with verbose=true (or with java -jar proguard.jar @myconfig.pro -verbose).

I would also suggest to use -keepnames option (see manual) for GamePanel and/or tileOffline since it will leave these classes unchanged by the obfuscation (at least for finding the root cause of the problem).

A side note is try to use CamelCase class names when programming in Java.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top