java Proguard injars 和 libraryjars

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10789557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 02:35:09  来源:igfitidea点击:

Proguard injars and libraryjars

javaobfuscationproguard

提问by Refugio Harmer

I have exported Java SE application with multiple 3rd party libraries using Eclipse's Export as Runnable JAR file menu. How I must set the injarsand libraryjaroptions of Proguard to obfuscate this application?

我已经使用 Eclipse 的“导出为可运行 JAR 文件”菜单导出了带有多个 3rd 方库的 Java SE 应用程序。我必须如何设置Proguard的injarslibraryjar选项来混淆这个应用程序?

Like this?

像这样?

  • injars MyApp.jar

  • injars 3rd party lib

  • injars second 3rd party lib etc

  • libraryjar ${java.home}/lib/rt.jar

  • libraryjar ${java.home}/lib/jsse.jar

  • libraryjar ${java.home}/lib/jce.jar

  • injars MyApp.jar

  • injars 3rd 方库

  • injars 第二第三方库等

  • libraryjar ${java.home}/lib/rt.jar

  • libraryjar ${java.home}/lib/jsse.jar

  • libraryjar ${java.home}/lib/jce.jar

So I must set the 3rd party libraries as injarsand ${java.home}/lib/*as libraryjar?

所以,我必须将第三方库,injars${java.home}/lib/*libraryjar

回答by Emmanuel Bourg

injarscontains the jar you want to obfuscate, and libraryjarsthe 3rd party libs that are not obfuscated.

injars包含要混淆的 jar,以及libraryjars未混淆的第 3 方库。

回答by Chuanhang.gu

  • -injars class_path
  • -injars 类路径

Specifies the input jars (or aars, wars, ears, zips, apks, or directories) of the application to be processed. The class files in these jars will be processed and written to the output jars. By default, any non-class files will be copied without changes. Please be aware of any temporary files (e.g. created by IDEs), especially if you are reading your input files straight from directories. The entries in the class path can be filtered, as explained in the filters section. For better readability, class path entries can be specified using multiple -injars options.

指定要处理的应用程序的输入 jar(或 aars、wars、ears、zip、apks 或目录)。这些 jar 中的类文件将被处理并写入输出 jar。默认情况下,任何非类文件都将被复制而不做任何更改。请注意任何临时文件(例如由 IDE 创建的),尤其是当您直接从目录读取输入文件时。可以过滤类路径中的条目,如过滤器部分所述。为了更好的可读性,可以使用多个 -injars 选项指定类路径条目。

  • -libraryjars class_path
  • -libraryjars 类路径

Specifies the library jars (or aars, wars, ears, zips, apks, or directories) of the application to be processed. The files in these jars will not be included in the output jars. The specified library jars should at least contain the class files that are extended by application class files. Library class files that are only called needn't be present, although their presence can improve the results of the optimization step. The entries in the class path can be filtered, as explained in the filters section. For better readability, class path entries can be specified using multiple -libraryjars options. Please note that the boot path and the class path set for running ProGuard are not considered when looking for library classes. This means that you explicitly have to specify the run-time jar that your code will use.Although this may seem cumbersome, it allows you to process applications targeted at different run-time environments. For example, you can process J2SE applications as well as JME midlets or Android apps, just by specifying the appropriate run-time jar.

指定要处理的应用程序的库 jar(或 aars、wars、ears、zip、apks 或目录)。The files in these jars will not be included in the output jars. The specified library jars should at least contain the class files that are extended by application class files. Library class files that are only called needn't be present,尽管它们的存在可以改善优化步骤的结果。可以过滤类路径中的条目,如过滤器部分所述。为了更好的可读性,可以使用多个 -libraryjars 选项指定类路径条目。请注意,在查找库类时不考虑为运行 ProGuard 设置的引导路径和类路径。This means that you explicitly have to specify the run-time jar that your code will use.尽管这看起来很麻烦,但它允许您处理针对不同运行时环境的应用程序。例如,您可以处理 J2SE 应用程序以及 JME midlets 或 Android 应用程序,只需指定适当的运行时 jar。

My result`

我的结果`

  1. -injars MyApp.jar
  2. -libraryjars ${java.home}/lib/rt.jar
  3. -libraryjar ${java.home}/lib/jsse.jar
  4. -libraryjar ${java.home}/lib/jce.jar
  1. -injars MyApp.jar
  2. -libraryjars ${java.home}/lib/rt.jar
  3. -libraryjar ${java.home}/lib/jsse.jar
  4. -libraryjar ${java.home}/lib/jce.jar

As for 3rd part lib,there has some difference.

至于第三部分库,有一些区别。

The specified library jars should at least contain the class files that are extended by application class files. Library class files that are only called needn't be present

指定的库 jar 至少应包含由应用程序类文件扩展的类文件。只调用的库类文件不需要存在

,so 3rd part lib may not need set.

,所以第三部分库可能不需要设置。

回答by GingerHead

The following are true:

以下是正确的:

-injars MyApp.jar

-libraryjars 3rd party lib

Don't put system paths for example: ${java.home}proguardwill not understand.

例如不要放系统路径:${java.home}proguard不会理解。