使用proguard混淆Java代码

对于Java Web项目,使用Netbeans作为IDE环境,想实现自动混淆class文件。因为Web项目,所以一些类是不能混淆的:

1. web.xml中涉及的类名称、package名称
2. 返回前端的数据涉及到的类名称、属性名称…

proguard的运行方法是执行proguard.sh @<cfg_file.cfg>

web项目,一般输入需要混淆的是WEB-INF/classes/下的相关class文件,要把WEB-INF/lib/下的相关jar文件都设置为libraryjars

proguard配置文件示例:

-injars /Users/xxx/NetBeansProjects/yyy/build/web/WEB-INF/classes
-outjars /Users/xxx/neto_classes

-dontshrink
-dontoptimize

-libraryjars /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/rt.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/asm-all-repackaged-2.2.0-b21.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/cglib-2.2.0-b21.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/cglib-2.2.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-beanutils-1.8.0.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-codec-1.3.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-collections-3.2.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-digester-2.0.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-fileupload-1.2.2.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-httpclient-3.0.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-io-2.0.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-lang-2.5.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-logging-1.1.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-logging.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-pool-1.6.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/commons-primitives-1.0.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/eclipselink.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/ezmorph-1.0.6.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/guava-14.0.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/hk2-api-2.2.0-b21.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/hk2-locator-2.2.0-b21.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/hk2-utils-2.2.0-b21.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/javax.annotation-api-1.2.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/javax.inject-2.2.0-b21.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/javax.servlet-api-3.0.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/javax.ws.rs-api-2.0.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jaxb-api-2.2.7.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jersey-client.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jersey-common.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jersey-container-servlet-core.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jersey-container-servlet.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jersey-entity-filtering-2.5.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jersey-media-moxy-2.5.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/jersey-server.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/json-lib-2.4-jdk15.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/ojdbc5.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/org-apache-commons-logging.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/org.osgi.core-4.2.0.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/osgi-resource-locator-1.0.1.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/persistence-api-1.0.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-aop-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-aspects-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-beans-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-build-src-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-context-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-context-support-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-core-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-expression-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-framework-bom-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-instrument-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-instrument-tomcat-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-jdbc-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-jms-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-orm-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-oxm-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-struts-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-test-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-tx-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-web-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-webmvc-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/spring-webmvc-portlet-3.2.7.RELEASE.jar
-libraryjars /Users/changzhenghe/NetBeansProjects/RmsPlus/build/web/WEB-INF/lib/validation-api-1.1.0.Final.jar

-ignorewarnings
-keeppackagenames com.**
-keeppackagenames sun.**
-keeppackagenames oracle.**
-keeppackagenames org.**
-keeppackagenames java.**
-keeppackagenames javax.**
-keeppackagenames jdk.**
-keeppackagenames net.sf.**

-keepattributes *Annotation*

# Keep - Applications. Keep all application classes, along with their 'main'
# methods.
#-keepclasseswithmembers public class * {
# public static void main(java.lang.String[]);
#}

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
public **[] values();
public ** valueOf(java.lang.String);
}

# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver

# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
# along with the special 'createUI' method.
-keep class * extends javax.swing.plaf.ComponentUI {
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
}

# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * {
native <methods>;
}

-keep class * extends javax.servlet.http.HttpServlet
-keep class net.skyatlas.ee.RmsPlus.webapi.*
-keep class net.skyatlas.ee.RmsPlus.domain.*
-keep class net.skyatlas.ee.RmsPlus.comm.*
-keep class net.skyatlas.ee.RmsPlus.util.RSAPemCoder

-keepclassmembers class net.skyatlas.ee.RmsPlus.comm.* {
private <fields>;
public <methods>;
}

-keepclassmembers class net.skyatlas.ee.RmsPlus.domain.* {
private <fields>;
public <methods>;
}

#-keepclassmembers class net.skyatlas.ee.RmsPlus.comm.DateAdapter {
# private <fields>;
# public <methods>;
#}

#-keep public class com.bpo.offerlist.util.Constant
#-keepclassmembers class com.bpo.offerlist.util.Constant {
# public protected private <fields>;
#}
#
#-keep public class com.bpo.offerlist.manager.JJJ
#-keepclassmembers class com.bpo.offerlist.manager.JJJ {
# public <methods>;
#}
#
#-keep public class com.bpo.offerlist.util.DebugHelper
#-keepclassmembers class com.bpo.offerlist.util.DebugHelper {
# public <methods>;
# public static <methods>;
# public protected private <fields>;
#}

117 Comments

  1. Pingback: mizuno sala classic ii as safety yellow turquoise soccer sneakers

  2. Pingback: baby byron maxwell 41 seattle seahawks jersey

  3. Pingback: big boys nba shoes big boys lebron 16

  4. Pingback: timberland nellie navy blue twitter.com

  5. Pingback: uk trainers nike roshe distance chocolate

  6. Pingback: all black free runs

  7. Pingback: adidas zx flux beige youtube.com

  8. Pingback: uk trainers air jordan 11 win like 82 white university blue midnight navy for sale

  9. Pingback: beats by dre red headphones

  10. Pingback: gr眉n schwarz nike hyperdunk 2016

  11. Pingback: kd6 khaki light uk trainers

  12. Pingback: fila disruptor sandals white uk trainers

  13. Pingback: nike hyperdunk 2015 hightop men sneakers 749562 619

  14. Pingback: nike cortez online store pinterest.com

  15. Pingback: big boys nba shoes big boys nike hyperdunk 2017

  16. Pingback: uk trainers adidas nemeziz 17+ 360 agility carmine rose

  17. Pingback: volt blanc blanc adidas superstar mesh

  18. Pingback: rojo rosado nike air max 360 2013

  19. Pingback: youth big boys skate adidas boys y3 nomad star low

  20. Pingback: caqui voltio nike air max 90 ultra mid winter se

  21. Pingback: nike revolution 3 mens wide pinterest.com

  22. Pingback: blau lila toms vegan canvas

  23. Pingback: jaune violet rouge jordan 31 low

  24. Pingback: khaki volt girls shoes

  25. Pingback: uk trainers nike lebron 14 black glow in the dark

  26. Pingback: uk trainers grade school toms vegan leopard

  27. Pingback: uk trainers round shaped shades

  28. Pingback: wholesale burnley fc kevin long 28 away jersey

  29. Pingback: uk trainers adidas campus green

  30. Pingback: adidas x white mountaineering eqt support 93 17 eqtdeep red whiteba7480

  31. Pingback: 斜械谢褘泄 泻芯褉懈褔薪械胁褘泄 adidas crazy explosive 2017 primeknit

  32. Pingback: ghost x easton bat

  33. Pingback: 褉芯蟹芯胁褘泄 泻芯褉懈褔薪械胁褘泄 curry 2.5

  34. Pingback: womens resolve jacket

  35. Pingback: oro blanco adidas predator instinct ag

  36. Pingback: rihanna in fenty puma pinterest.com

  37. Pingback: nike sportswear air max mens woven jacket blackblackblackwhite

  38. Pingback: aj shoes super fly 2 nike zoom air high christmas ver black

  39. Pingback: nike kyrie 4 all star 4 aq8623 001

  40. Pingback: mujeres entrenadores skechers entrenadores blanco negro skechers u86z4018

  41. Pingback: amiel carlos hm tribal cap giordano hoodie jacket hm flannel shirt giordano

  42. Pingback: nike mercurial victory vi

  43. Pingback: soft mesh golf hats

  44. Pingback: adidas cap tokyo fashion news

  45. Pingback: fascinating puma eskiva mid black shock pink sun

  46. Pingback: timberland mujeres 6 inch boots rosado blanco timberland timberland boot boys

  47. Pingback: north face tracksuit purple

  48. Pingback: dark green bodycon dress

  49. Pingback: desigual bols london across body bagssac desigual saledesigual cheapdesigner fashion

  50. Pingback: solebox x reebok pump omni zone rmation

  51. Pingback: women robe ladies warm bath robe

  52. Pingback: air jordan 11 xi low ie white gym red black release date top 919712 101

  53. Pingback: nisun stylish cotton sling cross body messenger college one side shoulder bag for men women olive

  54. Pingback: power rangers pyjamas 3 7 years power rangers pjs w14 5 6 years amazon.co.uk clothing

  55. Pingback: ua curry 2 men twitter.com

  56. Pingback: new nike benassi jdi mens blackgame red white 343880 006 slide

  57. Pingback: prada wingtip brogue platform sneakers flats 503153783

  58. Pingback: marco island water sports add a caption

  59. Pingback: michelle mason michelle mason plunge gown goxip

  60. Pingback: warrior ritual g3 sr goalie leg pads

  61. Pingback: custom nike kd 7 vii fireworks black white metallic gold for

  62. Pingback: asics gel lyte iii x david z black patent

  63. Pingback: nike air force 1 upstep lx 898421 101 898421 602

  64. Pingback: shop jerseyboots sale

  65. Pingback: nike air force 1 mid 07 prm qs flax 715889 200 wheat men women sneakers shoes original quality classic af1 basketball shoes sizes 36 46 shoes sale sneakers

  66. Pingback: its a trendy candy teen a line white black piece dress sexy see through dress semi girls dresses

  67. Pingback: new balance black brown men shoe

  68. Pingback: blue parka jacket mens asos

  69. Pingback: third pharrell x adidas nmd hu erd

  70. Pingback: the north face goretex work cap north face hat cap waterproof trekking outdoors men men women women unisex sale

  71. Pingback: hater strapback hat 1705

  72. Pingback: nike club swoosh jogger red 804408 657

  73. Pingback: jerseys kelme campus m c jersey shirts set tracksuit ttrcsz ttrcsz

  74. Pingback: reebok zprint 3d running black women shoes reebok princess usa

  75. Pingback: set five blue evil eye glass keychain ring

  76. Pingback: awake ny men s yellow metallic

  77. Pingback: image via nike stores twitter

  78. Pingback: winter pajamas wine

  79. Pingback: rayban glasses frames boys sunglasses compare prices and buy online

  80. Pingback: magnetic phone case iphone 7 plus design for moto x play xt1563 cases hard mobile phone

  81. Pingback: jd sports jd sports fitness athleisure wear lookbook girlie gossip

  82. Pingback: vans~034wahoo039s fish tacos

  83. Pingback: nike athletic pants

  84. Pingback: nike pg 1 men greyolive

  85. Pingback: 褋械褉械斜褉褟薪褘泄 泻褉邪褋薪褘泄 popcorn shoes

  86. Pingback: c茅line eyewear roundframe glasses womens gold

  87. Pingback: nike air jordan 1 white red mens basketball shoes

  88. Pingback: 4 pics 1 word answer 5 letters for fat cartoon pig redhead woman with ringlets

  89. Pingback: khaki grau adidas nmd city sock pk

  90. Pingback: puma r698 kosma pack

  91. Pingback: north face infant snowsuit 3 6 months

  92. Pingback: official licensed geniune fc barcelona messi 10 navy

  93. Pingback: a white purple sole does the restexpect more updates images of sneaker in the near futureair jordan 1 retro high bhm

  94. Pingback: nike hyperdunk 2017 high draymond

  95. Pingback: gucci and cabana green and black sundress

  96. Pingback: cold weather wet weather snow gear

  97. Pingback: foam bubbles key ring

  98. Pingback: wei脽 gr眉n nike free 5.0+ laf

  99. Pingback: evelyn glaser 8 of iron mountain recently had her first haircut and decided to donate it to wigs for kids an organization that provides wigs to children

  100. Pingback: womens nike vapormax plus grape

  101. Pingback: air jordan 1 low black white red shoes jordan space

  102. Pingback: rayban rx 7047 5573 matte havanna

  103. Pingback: cute girls woman cat cllaw flip flops japan anime game neko atsume cute cat cosplay

  104. Pingback: ray ban 0rb3136 caravan sunglasses price in doha qatar compare prices

  105. Pingback: rating dancing clothes for girls

  106. Pingback: this burgundy velvet boyfriend blazer is so fun to wear and on trend for this seasonjcathell blog velvetblazer boyfriendblazer burgundyblazer

  107. Pingback: high brief bikinis

  108. Pingback: back in the 1990s beanie babies little stuffed

  109. Pingback: pure wool reindeer tassel hat white aubergine red

  110. Pingback: wholesale nike lebron ambassador 9 camouflage army green mens

  111. Pingback: armada adidas x 15.2 fg

  112. Pingback: purple iphone 6s plus case

  113. Pingback: the north face unisex field bag waist pouch

  114. Pingback: mane concept brown sugar 6 deep side part full wig bs1602

  115. Pingback: nike pro girls capri

  116. Pingback: converse breakpoint pro ox white obsidian ankle high canvas fashion sneaker

  117. Pingback: reversible banner beanie

Leave Comment