Extracting .java from .jar and .class
Steps to be followed,
1. Type Hello world program.
2. Convert .java to .class file.
3. Convert .class to .jar file.
4. Convert .jar to .class
5. Convert .class to .java
Step 1: Consider the below program, (hello world program)
package mygod; public class Hello { public static void main(String[] args) { System.out.println("God is there...!!"); } }
Step 2: Converting .java to .class
javac Hello.java command.
This command will generate Hello.class from Hello.java file.
Step 3: Converting .class to .jar
jar cf Naveen.jar Hello.class
Now Naveen.jar file is generated from the Hello.class file.
Step 4: Converting .jar to .class
jar xf Naveen.jar
Now Hello.class and META-INF folder created.
Step 5: Converting .class to .java
We are searching the command for this problem. Don not worry. Anyhow we have some solution.
Just go to the below link,
http://www.softpedia.com/progDownload/JAD-Download-85911.html and download the jad software.
In that you can have jad.exe as well as readme file.
put both the jad.exe and your class file(need to be extracted) in some location. Consider desktop for easy understanding.
Open the command prompt and
jad Hello.class (now Hello.jad will be generated)
jad -s java Hello.class (now Hello.java has been generated)
Extracted .java from .class is: