简体   繁体   中英

How To Change Package Name In DOT-CLASS file if We don't have .Java File For that related classes

我有.class(点类文件)文件,在该文件中有一些要更改的软件包名称,但是对于这些.class文件,我没有相关的源代码,任何人都可以告诉我,我将如何更改软件包名称这些点类文件中,是否有可能

There are multiple options

  1. Decompile the class using tools like jad, edit the decompiled file and then recompile it. This is not easy as you might have to have all dependencies properly packaged to recompile
  2. Edit .class file using a byte code editor like http://set.ee/jbe/ and replace occurrences of package name. This may end up causing some unexpected behaviours if the class depends on variables with default scope its original package.
  3. Use ant task jarJar ( some details ) and then achieve the repackaging.

    Disclaimer : I have not tried these ever. I would rather leave .class files alone. And if you are facing a conflict, it is better to think of some modularity solutions or maven modules or maven shaded jars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM