I am having a jar file. It contains .class and .java files. I need to make changes in the jar file and those changes should be reflected in the .class file. Is there any way to do the same. I am using Netbeans 8.0. I am not getting any correct way after searching a lot. Please help me with a solution.
Asked
Active
Viewed 1,100 times
0
-
Possible duplicate of [How can I edit a .jar file?](https://stackoverflow.com/questions/4837500/how-can-i-edit-a-jar-file) – LuFFy Jun 02 '17 at 06:28
-
If I'm not mistaken, a `.jar` is already compressed, meaning you can't change anything inside it, unless you extract it, change the `.class` file then re-compress – Carl Binalla Jun 02 '17 at 06:29
-
please retag with Java and not JavaScript – mtizziani Jun 02 '17 at 06:35
-
how to edit the .class file? – Leeza Jun 02 '17 at 06:37
-
Possible duplicate of [Modifying a file inside a jar](https://stackoverflow.com/questions/1224817/modifying-a-file-inside-a-jar) – Noel Widmer Jun 02 '17 at 08:30
1 Answers
1
You cannot just "edit" a class file (within a jar or not). At least not in a useful manner. You would have to recompile the class. You could replace the class file in the jar, but that can easily lead to problems (a coworker of mine once replaced a file in a jar which then didnt work at all anymore).
It's better to just repackage your jar. If it takes you more than 2 clicks or one command line call to clean, compile and package your project, you're doing it in an unnecessary hard way.
Using your IDE, or some build tool like ant or maven (both can do more than just build) it shouldn't be much of a problem for you to edit your java file and recompile and package the project.

Dennux
- 240
- 1
- 8