File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes How to get Java file from .class file ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Storm Applied this week in the Other Open Source APIs forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get Java file from .class file ?" Watch "How to get Java file from .class file ?" New topic

How to get Java file from .class file ?

Ja vardhan
Ranch Hand

Joined: May 09, 2005
Posts: 169

How can we get source Java code from the compiled .class file ?


Vinayak Kulkarni

Joined: Dec 11, 2005
Posts: 8
Using any Java de-compiler you can get java file from its class file

SCJP 1.4<br /> <br />preparing for SCWCD
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42955
Jad (google for it) and Jode (on SourceForge) are quite good.
Adam Richards
Ranch Hand

Joined: Nov 03, 2005
Posts: 135
But don't assume you'll be able to understand it very well, since comments, design philosophy, etc. will be absent.
Amit K Srivastava

Joined: May 16, 2006
Posts: 23
Is there any option(s) available through which I can prohibit my class from getting decompiled?

--Amit Srivastava
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42955
You can make it progressively harder, but a technically sophisticated user will always be able to recover the bytecodes, and run that through a decompiler.

If you can require the user to be online, it may be feasible to have the application call a servlet, and execute crucial code on the server, and then send the results back to the application.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
mind that the same is valid for any code, written in any language, for any platform.

Tomas Anderson

Joined: Feb 26, 2006
Posts: 16
If you don't want your users to have to connect to a servlet (ie - you want an application or an applet), you can obfuscate your code.

Obfuscation is the practice of making your Java code so complicated and confusing that nobody can tell what's happening. A good obfuscator makes your code ridiculously complex while not sacrificing too much speed. You would usually use download a program to obfuscate your code for you, and keep separate versions of the code - one for development and an obfuscated version.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
We use a product that logs things like Exception A thrown by a.a.a.b.c.d.X o()

I've never felt the least urge to decompile it.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Raghavendra nandavar
Ranch Hand

Joined: Jun 26, 2005
Posts: 231
Originally posted by Ja vardhan:

How can we get source Java code from the compiled .class file ?


You can use the Java DJ Decompiler to get the source file
from the class file.
Casper Maxwell
Ranch Hand

Joined: Aug 04, 2005
Posts: 88
These two list may help you:
I agree. Here's the link:
subject: How to get Java file from .class file ?