Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert .class to .java

Tags:

java

I have some .class files that I need to convert to .java so I did:

javap -c ClassName.class 

and all the time I have the same error

ERROR:Could not find ClassName.class 

Do you guys have any idea of what might be the cause? I did man javap and as far as I know, the syntax is correct. If there is another way to convert it to a .java file, I am more than willing to try.

like image 272
fabricemarcelin Avatar asked Jun 03 '11 09:06

fabricemarcelin


People also ask

Can we create Java file from class file?

To create a new Java class or type, follow these steps: In the Project window, right-click a Java file or folder, and select New > Java Class. Alternatively, select a Java file or folder in the Project window, or click in a Java file in the Code Editor. Then select File > New > Java Class.


1 Answers

Invoking javap to read the bytecode

The javap command takes class-names without the .class extension. Try

javap -c ClassName 

Converting .class files back to .java files

javap will however not give you the implementations of the methods in java-syntax. It will at most give it to you in JVM bytecode format.

To actually decompile (i.e., do the reverse of javac) you will have to use proper decompiler. See for instance the following related question:

  • How do I "decompile" Java class files?
like image 50
aioobe Avatar answered Sep 21 '22 11:09

aioobe