ARF
ARF

Reputation: 7684

Decompile & recompile single file from jar

This problem has been solved witht he help of the comments:

It was necessary to recompile the java with the correct target version. In my case javac -source 1.3 -target 1.3 instead of simply javac did the trick.

Problem Description:

I have a compiled .jar java program in which a single url string needs to be modified. Using JD I was able to decompile the code and make the changes.

As I would like to avoid having to recompile the entire project I thought I could simply recompile the single .java file I modified into a .class and replace the original with it.

However, after repackaging the jar, the program does start but the functionality making use of the code I modified behaves erratically.

In the log 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(ResourceBundle.java:842)

ModuleResources.java is the file I modified...

Analysis of the problem:

  1. Repackageing is not at fault: if I extract and repackage the original jar, everything works.
  2. My modification does equally not seem to be the problem: when I recompile the JD-decompiled java file and use the resulting class file for repackaging, I get the same failure.

I decompiled the repackaged jar file and compared it with the decompilation of the original jar file: In the file I modified (at least) the code seems to be identical BUT JD shows different line numbers. Could that hint at the problem?

Any help would be greatly appreciated.

Many thanks!

Upvotes: 3

Views: 8429

Answers (2)

Star_Man
Star_Man

Reputation: 1091

This is the old question.

Nowadays, I found the good method to decompile and repack the jar file.

Here is the good document.

https://www.talksinfo.com/how-to-edit-class-file-from-a-jar/

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

Upvotes: 1

NPE
NPE

Reputation: 500257

when I recompile the JD-decompiled java file and use the resulting class file for repackaging, I get the same failure

This seems to point the finger at JD. When you recompile the JD-decompiled java file, can you compare the result with the original .class file (for example, by disassembling both and comparing the result)? If they differ in substance, that'll lend credence to the theory that JD is at fault; if they don't, then the problem lies elsewhere.

Upvotes: 0

Related Questions