New Compiling Question

I have decompiled a .jar archive to edit it. Now ive decompiled it successfully and made my changes, but in .JAD form. when i decompiled the archive i got .class files. when i went to edit them they became .java files, now i want to compile the edited .jar files back into the main .jar. how can id o this?

[313 byte] By [Therompstera] at [2007-11-27 2:13:34]
# 1

> I have decompiled a .jar archive to edit it. Now ive

> decompiled it successfully and made my changes, but

> in .JAD form. when i decompiled the archive i got

> .class files. when i went to edit them they became

> .java files, now i want to compile the edited .jar

> files back into the main .jar. how can id o this?

I used jad too not far away..

you said when you decompile you get .class and .java when edited.. it's a mistake?

you have to get .class when the .jar is decompressed and .java when decompiled..

In other way, answering what i've understood, you can recompile the decompiled .java files into new .class and create the .jar again.

Also, if you only have modified one .class not the others you can put the new .class file into the .jar using a compression tool like winrar (this way you can have version problems, but it can work correctly if all .class work in the same version).

alexpallarsa at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 2
so what can i use to compile the .java files back into .class files and then the .class files back into the .jar archive?
Therompstera at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 3
What do you usually use to compile Java source code? and so far as jarring goes, you just use the jar command.
abillconsla at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 4

> so what can i use to compile the .java files back

> into .class files and then the .class files back into

> the .jar archive?

you must have a jdk installed (or an IDE wich includes it) to compile the .java generated via jad. then, at the root directory where you could have the .class files execute

jar -cvf whatyouwant.jar *

alexpallarsa at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 5

i decompiled a .jar archive with dj decompiler, and i got all the .class files and all, now when i use dj decompiler to try and edit the class file, it will auto matically convert it to a .jad file, so i do the edits i want to do but when i go to save it i cannot save it back into a .class format. so i save it into a .java format.

when i try to recompile the .java file into a .class file i get 100 errors. all i really want to do is edit ONE text line in three different class files in this jar archive. there are about 90 class files in the archive, is tehre any way to go into the class files, edit them and put them back exactly where they were? what programs do i need, i have the jdk with the javac exe file. and i also know that there shouldnt be any problems with the edits i am doing, because all i am doing is changing a path from (ex:c:/program files/ to c:/) what can i do?

Therompstera at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 6

First of all you don't decompile a jar file. You simply unjar it using either the jar tool, or, if you have Winzip - for example - you can drop the .jar file onto it and then just extract the class files out - IOW - you need to extract the class files in any case - not decompile them. Jar files are in Zip file format and are not compiled at all, only - at times - decompressed.

Second of all, you started talking about [url http://www.kpdus.com/jad.html]JAD[/url], but now you are talking about dj ... what is that?

Thirdly, if you are getting 100 errors when you recompile the .java files then you did something very wrong.

abillconsla at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 7

ok first of all thank you for clearing up the decompiling....unzipping issue.

and when i started talking about jad files this is what i meant :

dj decompiler is a tool, that will take a jar archive, un(jar) it and show you all the .class files. but it will not edit the class file as it is. what it does is change it to a .jad file when i double click the class file so i can edit it. then when i want to save it it will save it into .jad files or into .java files. so after i edit the.class files(turned .jad) i have no way of putting them back into class files and back into the archive.

Therompstera at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 8

I did not read much on the link I provided in my previous post, so I don't know much to speak of about JAD. However, if it really does decompile the .class file and allows you to edit and then save it into a .java file, you ought to be able to recompile it into a .class file using the javac command, no? Did you try this? If so, and this is what is giving you the 100 errors, then show the errors - or an example of one error in case they are repetitious.

~Bill

abillconsla at 2007-7-12 2:09:05 > top of Java-index,Java Essentials,Java Programming...
# 9
yes that is what i did, but i got these errors ap.java:92 cannot find symbolsymbol:class bglocation :class apbg bg1 = bg.a();and its a bunch of those 100 im guessing because at the bottom it tells me there were 100 errors.
Therompstera at 2007-7-12 2:09:06 > top of Java-index,Java Essentials,Java Programming...
# 10
is there any way i can give you the jar file and see if you can get what i cannot get accompilshed, or is that a no no here?:
Therompstera at 2007-7-12 2:09:06 > top of Java-index,Java Essentials,Java Programming...
# 11

Sounds dubious to me, from the legal point of view. They didn't give you source code, and the compiled classes they gave you look to me as if they are obfuscated. Obviously they don't want you messing with their code.

So I don't think you're going to get anybody here to help you out with that exploit.

DrClapa at 2007-7-12 2:09:06 > top of Java-index,Java Essentials,Java Programming...
# 12

> Sounds dubious to me, from the legal point of view.

> They didn't give you source code, and the compiled

> classes they gave you look to me as if they are

> obfuscated. Obviously they don't want you messing

> with their code.

>

> So I don't think you're going to get anybody here to

> help you out with that exploit.

AH! naive little me - that is a very good point, and one I did not think of. It may well not be the case, but it's a bit of a hot potato I should say.

abillconsla at 2007-7-12 2:09:06 > top of Java-index,Java Essentials,Java Programming...
# 13

well, it's true it can be illegal to decompile, change and use the jar...

in it's case it would be his problem not our, so i don't think it's a problem to solve the issue, because can be people who need an answer for legal use (he also).

so, i'll tell what i had to do one time to reuse a jar at work with a decompile tool...

well, first of all, a decompile tool it's not 100% reliable so you can get error because it's not well decompiled, but you can:

1. Extract all .class files from the jar

2. Decompile the .class file you need to modify.

3. Make the source changes you need

4. Compile the new .java file using the other old .class files you've extracted from the jar. To do this put the changed .java at the same directory where you've extracted old .class so when you compile the .java only one .class will be updated.

5. Create a new .jar file

As you will use the old .class files you have'nt to be care about errors in them because they have to be ok.

And if there are errors in the new .java it's because it can had a bad decompilation, so you can make changes to solve it.

You can decompile all classes to view what they're doing but only recompile the one you've changed!

I have'nt used dj decompiler so i can't tell you "how to" do it, only "how can"

alexpallarsa at 2007-7-12 2:09:06 > top of Java-index,Java Essentials,Java Programming...
# 14
its defenitly for legal use all i want to do is have a mobile jar file execute from a different source path example //c/ instead of //a/
Therompstera at 2007-7-12 2:09:06 > top of Java-index,Java Essentials,Java Programming...