When a Java source code is compiled, it is converted into Java class file by the Java compiler with a .class extension. The class file contains highly optimized instructions in the form of Java instructions which is executed by the Java Virtual Machine or the JVM. .class file contains symbols with each bytecode instruction stored as one byte.
A Decompiler for Java has the capability to convert a .class file into Java source code. Although it may fail in giving the exact java source code, from which the .class file was generated, the majority of the code will be the same. A decompiler will be helpful in situations where you have lost the source code.
There are many decompilers available which provide offline services. You can download these applications and get the work done. They have good user interfaces and are friendly to work with. Here are Top 10 Offline Java DeCompilers.
JD Project can be used to decompile Java 5 bytecode or later versions. The reconstructed code can be accessed using the JD-GUI. It has a JD-Eclipse plugin which is to integrate JD Project with Eclipse and run it on Eclipse platform. During the process of debugging, it allows you to display all the Java sources. A plugin for IntelliJ is also available which is called JD-IntelliJ.
This plugin is under development, but you can still use it with available features. JD Project works with most of the compilers, and there are drag and drop and shortcut features. It allows even JAR and ZIP files. You can browse the files in a class hierarchy, and the logs are shown, and you can decompile class files appearing in Java stack traces.
Cavaj Decompiler for Java is a freeware which doesn't require Java to be installed to perform decompilation of a file. It can be used with Java applets, ZIP files, and JAR. Using the Class View feature, you can browse the reconstructed source code for instant access to methods and fields. It is a standalone application for Windows with a good user interface. Many keyboard shortcuts and edits enable the users to work smoothly with Cavaj Decompiler.
DJ Java Decompiler is a disassembler and decompiler for the latest Windows environments like Windows XP, Windows 2003, Windows Vista, Windows 7, Windows 8, 8.1 and 10. It can decompile complex Java applets and binaries, to produce accurate source code.
Again, DJ Java Decompiler is a standalone application which doesn't require Java, JVM or JDK to be installed. There are drag and drop features for smooth working, and you can decompile .class files on your computer's hard disk or on a network drive that you have connected.
JBVD or Java Bytecode Viewer & Decompiler is a powerful decompiler that uses javassist open source library for making the conversions of the .class file into Java source file. It is available for devices that run on Windows platform. The program needs Java to be installed on your device to work.
You can quickly make selections that prompt a file selection window in a single click. Just select the .java or .class file and the information will be showed in the designated panel. JBVD can thus work as both java viewer and decompiler.
AndroChef is a suitable Java decompiler to view and analyze bytecode. You can convert complex Java .class files and applets into Java source code. AndroChef is available on Windows operating systems only. Even obfuscated Java 6, Java 7 and Java 8 .class and .jar files can be smoothly decompiled.
It supports Java language features like generics, enums, and annotations. After selecting the file or section of the code, you can decompile it with the 'Decompile' button and records will be decompiled to the location you choose.
Procyon decompiler is a good option for converting the java files into .class files as it can handle language enhancements from Java 5 and beyond that most other decompilers don't. It can handle enum declarations, local classes, and annotations with ease. If you don't want to use the command line, then you can get a GUI front end and for Procyon. Procyon is under development but still it is new and supports the latest Java files.
Apart from these decompilers, there are a few other options as well. The decompilers mentioned below are in their nascent stage and are still under development. They are capable of functioning smoothly in command lines. You can get a GUI for these decompilers separately from the internet.
Fernflower is an analytical decompiler for Java. It is still under development and has become open sourced. It renames all the obfuscated symbols and puts them in a JAR file at the end.
CFR is written in Java 6 but has capabilities to decompile latest features of Java 8 lambdas and Java 7 String switches. To decompile an entire jar, you can simply provide the jar path and get the work done.
The decompiler options are plenty, and you can choose according to your needs. If you are looking for a decompiler with proper GUI and one click decompilation, opt for the traditional decompiler choices. The new ones under development, however, offer a lot of new features for decompilation to decompile obfuscated codes and the latest Java codes. They are also open for development.
Many of these Java decompilers are also Viewers so that even without having Java in your system, these work as standalone programs which enable you to work with Java code even without having Java installed in the system.