Proguard Top Level Obfuscation

Posted on 2009-02-17
Last Modified: 2013-11-24
Hopefully, I can find someone with some Proguard JAVA obfuscation experience.

Here's their website,

I have a java servlet application with a directory structure as follows:

I'm finding when I run proguard on this application using ant and specify the directory at this level, the obfuscated output jar file looks like this.

That is, the top level servlets don't get obfuscated. I've attached the proguard configuration file.
Does anyone know how to configure proguard to obfuscate the top level servlets?

x comes from the defaultpackage specification in the configuration file.

-injars '..\app.jar'

-outjars '..\o_app.jar'

-libraryjars '..\lib\rt_6_0.jar'

-libraryjars '..\lib\servlet-api.jar'

-defaultpackage x


# Keep - Servlets. Keep all extensions of javax.servlet.Servlet.

-keep public class * extends javax.servlet.Servlet

# Also keep - Enumerations. Keep a method that is required in enumeration

# classes.

-keepclassmembers class * extends java.lang.Enum {

    public **[] values();


# Keep names - Native method names. Keep all native class/method names.

-keepclasseswithmembernames class * {

    native <methods>;


#Javascript classes

-keepnames class netscape.javascript.JSObject

-keepnames class netscape.javascript.JSException

# Remove debugging - Throwable_printStackTrace calls. Remove all invocations of

# Throwable.printStackTrace().

-assumenosideeffects public class java.lang.Throwable {

    public void printStackTrace();


# Remove debugging - All Log4j API calls. Remove all invocations of the

# Log4j API whose return values are not used.

-assumenosideeffects public class org.apache.log4j.** {



Open in new window

Question by:lcor
    LVL 86

    Accepted Solution

    Those top level classes should be in a package anyway, so why not move them into one?
    LVL 92

    Assisted Solution

    > -keep public class * extends javax.servlet.Servlet

    your telling it to keep servlets

    which you'd want to do so your config does not break


    Author Closing Comment

    I figured moving to a package was what I needed to do but was *hoping* otherwise.
    LVL 92

    Expert Comment

    we teach our students and web developers to always use packages. Avoids all the gotchas encountered when using the default package.
    Good to hear you got it sorted :)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Performance issue while iterating with streams 5 34
    triangle challenge 4 36
    countHi challenge 25 60
    network + 7 57
    Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
    Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now