Decompile and recompile one file from jar

This problem was solved with comments:

It was necessary to recompile java with the correct target version. In my case, javac -source 1.3 -target 1.3

instead of a simple one, I javac

did the trick.

Description of the problem:

I have a compiled java .jar program in which one line of url needs to be changed. Using JD I was able to decompile the code and make changes.

As much as I would like not to recompile the whole project, I thought I could just recompile the single .java file that I modified into .class and replaced it with the original.

However, after repackaging the banner, the program starts, but the functionality using the modified code behaves erratically.

In the magazine I find:

E EventDispatchThreadExceptionHandler:Unhandled exception occurred during event dispatching.::
java.util.MissingResourceException: Can't find bundle for base name com.myCompany.mySoftware.resources.ModuleResources, locale en_US
       at java.util.ResourceBundle.throwMissingResourceException( is the file I have modified ...

Problem analysis:

  • Re-packaging is not to blame: if I extract and repack the original jar everything works.
  • My change is equally not a problem: when I recompile the JD decompiled Java file and use the resulting class file to repackage, I get the same failure.

I decompiled the packaged jar file and compared it to decompiling the original jar file: in the file I modified (at least), the code seems to be identical. BD JD shows different line numbers. Could this hint at a problem?

Any help would be greatly appreciated.

Many thanks!


source to share

2 answers

when i recompile the JD decompiled java file and use the resulting class file to repackage i get the same failure

It seems to be pointing the finger at JD. When you recompile a JD decompiled Java file, can you compare the result with the original file .class

(for example, by parsing both and comparing the result)? If they differ in substance, this will support the theory that JD is at fault; if they don't, then the problem lies elsewhere.



This is an old question.

I have currently found a good way to decompile and repack the jar file.

Here's a good document.

I recommend the third way in the document. !!!



All Articles