Armandt Burger
Armandt Burger

Reputation: 21

can you create java file from the class file? Decompile

I recently created a project in Netbeans using VirtualBox on which i installed windows XP (Not activiated) My Windows required me to activate and would not allow me access to my files on the computer before i activate it, i stupidly went and uninstalled XP and reinstalled it, thinking i'll have access to all the files from the JAR file i created

I want to know if theres any way i can use the class files of the project i created, to create new java files so that i can edit the code in netbeans ??

Please if anyone can shed some light on this topic, if its at all posible to gain access to the forms java content i created. Im new to programming and this is something above my knowledge (i hope this makes sense)

If not possible please let me know what an absolute idiot i am, so that i can start re creating the project from scratch ... Sigh, and thank you

Upvotes: 0

Views: 4661

Answers (2)

SebastianH
SebastianH

Reputation: 2182

As a sidenote: You are lucky that its Java. In many other languages like C++ that would hardly be possible. The difference is that Java does not compile the source code to machine code. That step is hardly reversible since for example all variable names are lost. Try to understand a non-trivial piece of code without helpful variable names...

Java instead compiles the source code to byte code which then is interpreted by Java on runtime. That byte cold holds way more information about the original source code than machine code.

Upvotes: 0

nanofarad
nanofarad

Reputation: 41271

A jar/class file is compiled bytecode that is not human-readable... but with Java it is easily converted back. Look into a program like JavaDecompiler.1 This is not my program but I use it and I find it workable for my needs.

1 If this is considered spam I'll gladly invalidate the link.

Upvotes: 1

Related Questions