• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

decompilation of .class file into .java

 
Mr Anil Kumar Pandey
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody
can .class file decompiled into .java file and then after important modification and then after compilation be used as original?
thanks
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly am not sure if the decompiled version will be exactly same as that of the original file. Moreover, if you have a valid java file with all imports resolved, you can as well edit that file and compile it again. And for decompiling details- you can search in the Beginner or Java General forums.

This is somewhat not encouraged because you would be making use of some else's work. If the code is open sourced then you can download the source directly and this is fine because the original author wanted it to be shared and reused.
 
Mr Anil Kumar Pandey
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks

may i know what are free decompiler available.
is there decompiler plugine available there?
 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at http://java.decompiler.free.fr
 
Meherdad Bomanbehram
Ranch Hand
Posts: 142
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
many are available here
 
Mr Anil Kumar Pandey
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks

is decompile code(.class->.java) 100% reliable as original one
 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AFAIK there's no guaranty for a 100% success. I wouldn't rely on it.
 
Mr Anil Kumar Pandey
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mehmet Gunacti wrote:AFAIK there's no guaranty for a 100% success. I wouldn't rely on it.

sir thanks
i have a .class file.
original source file missed.
i have to change url in this file
how one can do it?
please tell me sir a successfull way
 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, create an empty project in your favorite IDE and put the original jar file into the build-path.

decompile the class, put the .java file into your source folder (preserve package structure).

after compilation just update the original jar file using Winrar, drag and drop the new class file and overwrite the original one.

That should do the trick ;)
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no reliable way to do this. Your decompiled java classes may well... not compile because the decompilation process is not fool proof.

You can however follow the approach mentioned by Mehmet. It will bring you closest to success.

Why are you decompiling anyway ? Did you lose the source ?
 
Maneesh Godbole
Saloon Keeper
Posts: 11196
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be a good idea to carefully read the license. Some licenses explicitly forbid decompiling.
 
Tommy Delson
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you just use Eclipse IDE to open .class file? Eclipse has everything you need for the project...harness the tool to it full power.

 
Randall Twede
Ranch Hand
Posts: 4482
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well mr pandy may be completely innocent, but i always thought one of the big advantages of compilers vs interpreters is that your source code is sate.
 
Rob Spoor
Sheriff
Pie
Posts: 20671
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Safe? No. You can do your best to make it hard to decompile, by using a code obfuscator, but in the end most of the code can be decompiled. After all, the JVM needs to be able to read the byte code, and therefore so can any decompiler.
 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question is, why did the designers of Java allow that ?

they must have discussed this, and accepted the fact that Java code will be decompilable.

Shouldn't they have included an option (parameter maybe ?) that would prevent decompilation ?

 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mehmet Gunacti wrote:the question is, why did the designers of Java allow that ?

they must have discussed this, and accepted the fact that Java code will be decompilable.

Shouldn't they have included an option (parameter maybe ?) that would prevent decompilation ?



The JLS and the class format are specifications. This means your specification can have a JVM vendor (Sun/IBM/JBOSS) and it allows for freedom. You need not be tied down with a vendor.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mehmet Gunacti wrote:. . . an option (parameter maybe ?) that would prevent decompilation ?
As Rob has already told us, if you can execute the bytecode you can decompile it. So it is not possible to prevent decompilation.
 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Mehmet Gunacti wrote:. . . an option (parameter maybe ?) that would prevent decompilation ?
As Rob has already told us, if you can execute the bytecode you can decompile it. So it is not possible to prevent decompilation.


You mean, if you can interpret the code, you can decompile it.

Still, there should be a mechanism like, compiling the java source code to binary instead of bytecode. the JVM should then be able to run binary-bytecode...

ok, I was just thinking loud.

AFAIK one is able to decompile .net code (intermediate language ?), too, right ? So I guess MS would have prevented that, if there would be a way to do it.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
run binary-bytecode...




Assembly you mean ? Here are some links that can clarify the matter for you

http://en.wikipedia.org/wiki/Bytecode

http://en.wikipedia.org/wiki/Assembly_language

http://en.wikipedia.org/wiki/Just-in-time_compilation
 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:
run binary-bytecode...




Assembly you mean ? Here are some links that can clarify the matter for you


Was just wondering why they didn't come up with a method to prevent decompiling Java classes.

It's not possible, I guess, that's why.

Yes, I meant assembly (or machine code). sorry for the inappropriate term.

Thanks for the links.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiling to machine code would tie your application to a particular platform. You would have to recompile a Windows® application to run on a Mac, for example.
 
Sam Hazim
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't had cause to look into it, but there are Java Obfuscators that will attempt to amend your class files to prevent/make decompilation difficult. If that's something that concerns you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic