2

I do Java development and I was wondering if there is a Java obfuscator that I can install on Ubuntu GNOME 16.04 with GNOME 3.20? That is one that I could give the code to and it would do things like make all the code go on one line and remove all indentation, change function and variable names etc to random values etc, to generally make the code harder to read and decompile. It would also be nice if it gave me the options of choosing which of these I want it to do to the code if not all.

2

Proguard does this and — best of all — it is available in the archives:

sudo apt-get install proguard

Usage

Assuming you have a file HelloWorld.java:

public class HelloWorld {
    public static void main(String[] args) {
        showMessage();
    }
    private static void showMessage() {
        System.out.println("Hello World!");
    }
}

You would first compile it with:

javac HelloWorld.java

Then you would create a JAR with:

jar cfe HelloWorld.jar HelloWorld HelloWorld.class

Running it through Proguard is as simple as:

proguard @config.pro

...where config.pro is:

-injars HelloWorld.jar
-outjars HelloWorld_out.jar
-libraryjars /path/to/rt.jar
-keep public class HelloWorld { 
      public static void main(java.lang.String[]); 
}

Note: change the path in libraryjars to the appropriate path for your JDK. If you are compiling with OpenJDK 8, for example, use this path:

/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy