简体   繁体   中英

Rename jar package name

I have a jar file but unfortunately I lost source code due to my disk crash. I just want to change its package name to some meaningful name.

Is there any way that I can change package name of jar file and of course I need to update this package name in class files.

I know about Java Decompiler but I just want to change its package name.

jarjar might be able to do this.

It's designed to build a single big jar containing an application and its supporting libraries. It supports moving the libraries into different packages to avoid naming conflicts (for example you could use two different versions of the same library with different package name prefixes).

It can probably be configured to do what you want.

The package name is included in the class file so there is no easy way.

Decompile it and then do the changes you need, and then recompile and repackage it.

If you use NetBeans IDE 6... for creating Jar package, you can simply change Jar file name to your alternative.

  1. Open file: "nbproject/project.properties" in your project directory [You can open it by drag&droping it to a Notepad window - run Notepad in windows by "Start/All Programs/Accessories/Notepad"].

  2. Change line: dist.jar=... to a new path. Eg dist.jar=${dist.dir}/f2.jar

  3. press "Build Main Project" or "F11" to build a new Jar file with the new name.

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