Decompile jar file to use it as a project in intellij - java

I have a jar file but not source code. I had some issue with this code which is not working as expected. So I want to decompile it use it as a project in intellij. Could you please let me know how can I do that?

You need a java decompiler, like jd-gui http://jd.benow.ca/

use jd-gui and copy the source code in intellij. also normally with decomiplation your code will have multiple localobject and you have to deal with it

Related

Java- how can get java code of class and jar files

I downloaded class files and jar files. I want to know is there any way to I can certainly get java code of these?
You cane make use of JAD for code de-compilation. Download jad from here.
There are some ways you can do that by using tools like dex2jar. But that will be generated code for the class. if you can, just ask the owner directly about it.
you can use java decompiler too link

Recreate project from .jar file

Is there any chance, to recreate a (netbeans-)project from a .jar file?
Becuase I trusted some silly cryption-software that corrupt's my file.
Is their any suggestion or solution?
I already extracted the .jar file with terminal commands 'jar xf MyJarFile.jar'.
But I can't read the code in it...
You could decompile the jar into the sources and then create a new project and drag all the sources into your src folder. I like using JD-GUI for decompiling .jars: http://java.decompiler.free.fr/?q=jdgui
I also recommend using JD-GUI, it helped me a lot when my simple text editor corrupted my .java files and I was able to convert the classes back into source using it.
delete the $ files first, then Jad is the best, jdgui makes errors.

Understanding JAVA code in external JAR libraries

I've been provided some external JAR libraries for a project I'm doing. I can access the compiled code but I can't really understand it as its not in the form I'm used to seeing. Any tips on how to 'de-code' and understand what's going on?
Thanks
Search the net for Java Decompilers (e.g. JAD). What you see in a jar is Java-Classes, i.e. the result of compiling .java files.
There are decomiplers you can use them to de-compile .class to .java. We are using JD Java decompiler.
NOTE: I think De-compilation (or) modifying de-compiled code is illegal in some countries. Be aware of it.
You could use a decompiler like JAD to decompile from .class file to .java files, but in my experience its use is quite limited
Try Java Decompiler (Yet another Fast Java decompiler) : http://java.decompiler.free.fr/ .
It can decompile your compiled library.
JAD is only supported up to 1.3.
There should be a documentation and/or source jar that you can attach to your IDE, which will allow you to access the documentation.
If not, you have to decompile it.
Keep in mind that it might be ok to treat this jar as a black box.

Eclipse how to see the Java file instead of class file

I want to see the java file when i click the respective object or it's method. I knew that java files are compiled and it will be in the .class format. Is it anyway to see as a java file in eclipse by using plugins or Anyother tool is there to achieve this? So we can avoid to see the implementation of the object and it's method in the java portal's..
If you have the source available then use Attach Source feature. If not then any decompiler eclipse plugin is fine. My preference is JD-Eclipse.
If you have the source code, you can attach it so that it gets opened automatically. This is explained in Is there an easy way to attach source in Eclipse?
If you don't have access to the source, you can integrate a Java decompiler into Eclipse: Java Decompiler
If you have the source of the library (jar) you can add it (in the properties) of the jar, otherwise you can use "decompiler" plugin: http://java.decompiler.free.fr/

Viewing source code from a third-party jar in Eclipse

I am working on a Java project in Eclipse. In this I am using a third party JAR which I have put in on the classpath. Now I want to understand the code in the JAR file and want to see the actual code and navigate through the third party code just like my own code.
My question is this: Instead of me manually decompiling all of the class files in the JAR and putting them in the appropriate folder as per package declaration, is there some way in which Eclipse will decompile them for me, and put them in the appropriate folder? What should be the approach taken in such a scenario?
The decompiler I use is JAD. It has an eclipse plugin, Jadclipse.
You can download JAD from http://www.varaneckas.com/jad
You can get Jadclipse from http://sourceforge.net/projects/jadclipse/. Click on the download jar and then simply copy the jar into your Eclipse/plugins directory, and restart Eclipse. Set up the path to JAD from Preferences->Java->JADClipse. Then trying to view a class should give the decompiled code.
I have been using Java Decompiler for some time and have found it very useful, i don't know about eclipse but it seems to have a eclipse plugin: JD-Eclipse

Categories

Resources