Raz Razman
Raz Razman

Reputation: 411

Java - How can I edit a class file

I have a self extracting exe file, if I open that file with 7-zip inside it I can see a bunch of java class files.

I need to make a simple change, if I open the class file in notepad, although it is a binary mess the change I need to make is an ascii value which is readbale in the text editor, if I edit the file, change it and update the archive, the application will no longer run. (Guess it sees the file as corrupted now)

How can I edit this file and put it back in the archive? Can I decompile the single class file, recompile it and put it back into the archive?

Upvotes: 1

Views: 35601

Answers (2)

Raz Razman
Raz Razman

Reputation: 411

Okay figured it out.

java Class editor is a small program they may work for basic files.

However I found this better way:

browse to the exe in 7-zip, right click and select "view inside" Browse to the folder containing the class file. Extract the class file to your pc. Open the class file with "Dirty Joe Java overall Editor" make the changes you need and be sure to click file/save./ Copy the file back into 7-zip and you have a working exe with the modification you just made. No need to decompile!

Upvotes: 6

Ivantha
Ivantha

Reputation: 521

No you can't. I think what you have to do is,

1) Extract the class files to somewhere.

2) Decompile everything.

3) Make your change.

4) Recompile all the java file.

5) Make a new self extracting archive.

*You can use a site like this to decompile
http://www.javadecompilers.com/

Upvotes: 1

Related Questions