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

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

Related

Decompile jar file to use it as a project in intellij

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

how can I edit a Java application using .CLASS files

I've been trying to edit the .CLASS files inside this program using .jar containers, and a .bat file to launch it.
I'm not familiar with Java, and I've tried Java decompilers but they don't let me edit the source, only copy it. I don't seem to have a program that can actually correctly save and encode it.
What's the best option here to easily edit this Java program's .CLASS files?
Edit: To everyone who's enjoying downrepping this, the program is open source and permits modifications. So thank you for all the blame flinging about it being illegal.
You could try decompiling it with Fernflower, editing the code, then compiling it back into a classfile with the normal javac.
There is no real "easy" way. You could edit the bytecode...but that is a bit more involved. You can use JD but, that as you said, is only so useful.
Use java de-compliler to get source code from byte code, modify as per you want save in different location(like copy source code with your modifications) then compile & run.

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.

Reading Java libraries

I am trying to open Motorola BLE API library for Android. I am not too familiar with Java so I am not sure if it is even possible.
When I try to open .class file from the library with notepad++ it contains something like:
Êþº¾ and black squares.
Is there a way to open them properly?
You can use the tool javap to disassemble .class files (= compiled Java code) but that won't tell you much.
Try to find the official documentation or the source (= .java files) by googling for the class name instead.
You will need to de-compiler to read the .class files. There are various available in the market, which are open source and free. Here is one
A .class file means that the library has already been compiled into Java's version of machine code, so you won't be able to view it in notepad. There are programs for decompiling class files back into source, but you need to make sure that a) you have the rights to do so, and b) that the particular decompiler supports the class file's particular version of Java.
For more information on decompilers, see this question:
How do I decompile Java class files?
If there source code (.java files) are provided , better use those. If not, then you have to use one of the de-compiler program. But even then if the code is obfuscated , even de-compiler would not be of any use. You have to use just the API documentation for any work.
Java is a compiled language where the source is compiled into machine readable bytecode. You have to disassemble/decompile the bytecode to get it into an even semi-readable form.
Also note that the license of the library very probably forbids you from disassembling it.
If you are really using to use the api in your application then here is the way:
See the documentation of the api that is provided.
Also import the classes in with the import statement. For eg put the classes in a new folder as "api" in current folder and the import statement would be as follows:
import api.*;
Then in the application logic make use of documentation on how to access the library.
Documentation here might help: https://developer.motorola.com/docs/bluetooth-low-energy-gatt-framework-api/

Convert .class file to .java file

Is this possible to convert a .class file (from .jar external library) to a .java file? I'm trying to figure out whether it is possible or not because the source of the external library is unavailable.
What are the steps I need to take to do this?
use a java decompiler like "Cavaj". It will open the class into a txt format, copy the code to a file and save as .java
Use jad. Download it from here. It works fine with classes compiled up to SDK 1.4... 1.5, if I recall correctly.
The javap command takes class-names without the .class extension. Try
javap -c ClassName
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.
http://download.cnet.com/Cavaj-Java-Decompiler/3000-2213_4-10071619.html
or may be this be of some help Java Decomilers
it is Possible to convert a class file to java file without using any tools . e.g Decompiler or something else ?

Categories

Resources