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.
Related
I have a .jar file and When I extract it, It gives me all the .class files present in that jar file.
I have decompiled all the .class files using http://jd.benow.ca/ tool but i want that all the .class files should save into .java files.
Right now i can see only the code but extension is not converting to .java.
Anybody Please help me in this.
you can use javadecompilers and its works perfectly
and in the next step you decompile with Upload and Decompileand this page be showing
and thats is just copy the package folder from the jarname.zip and paste it in you project.
i tested its work for me .
you can see this answer for more.
jd-cmd
https://github.com/kwart/jd-cmd
works fine for decompiling. I used it to convert whole jars into source code. Look up the command line options for more details, e.g. --outputDir for specifying a directory for the generated source code.
I'm using number of java files as common in different ADF projects, I want to archive them in jar file so I can import this archive file from any new project to use the java libraries in the project, I tried create it in jdeveloper but no luck.
Thank you for any advice,
You can use the following article to understand the way.
creating a Jar file
jar cf jar-file input-file(s)
But still you can zip a file using windows zip utility or winzip and rename it as a jar file. It is not official but it works.
No matter how big or small you project is, the best answer to this question IMHO is a build tool. I would recommend maven, it is a great tool. It will take some time to get into and it will probably slow down your pace at first but the rewards of knowing how to use a tool like that are very big.
http://maven.apache.org/
from your terminal - go to the directory where you have the files you want to jar and type the command
jar -cf myjarfile.jar *.java
hope this helps
see also:
Creating a JAR File
Assuming that the files that you want to reuse are related to ADF you should read about using ADF Libraries to increase reusability.
See: http://docs.oracle.com/cd/E16162_01/web.1112/e16182/reusing_components.htm#BEIGHHCG
I am using eclipse IDE and want to edit the attached source file of the jar file. For doing this i downloaded the src.zip and attached the file, but it is opening as a .class though I am able to read the file (which is a .class file) but i also want to edit the file.
Why I am not allowed to edit it? how to open an attached file with .java extension not .class extension.
thanks in advance
That's not possible. In order to edit the source, you have to unpack the JAR and create an eclipse project, from which you can then create a JAR with the modified code.
Because you have to link it... Source files are not tied to compiled classes in jar, so if you edit it, nothing will happen to the jar file
You have to create a separate project in Eclipse, and rebuild the jar with your modifications
.class files are not readable by human being unless you decompile it. Many decompilers exist. Carefull about what you are allowed to do and what you aren't, though...
Usually, .java aren't in .jar.
Is there a way to extract the source code from an executable .jar file (Java ME)?
Use JD GUI. Open the application, drag and drop your JAR file into it.
You can extract a jar file with the command :
jar xf filename.jar
References : Oracle's JAR documentation
I believe this can be done very easily. You can always extract the source files (Java files) of a jar file into a zip.
Steps to get sources of a jar file as a zip :
Download JAD from http://techieme.in/resources-needed/ and save it at any
location on your system.
Drag and drop the jar for which you want the sources on the JAD.
3 JAD UI will open with all the package structure in a tree format.
Click on File menu and select save jar sources.
It will save the sources as a zip with the same name as the jar.
Hope this helps.
The link is dead due to some reason so adding the link from where you can download the JDGUI
Your JAR may contain source and javadoc, in which case you can simply use jar xf my.jar to extract them.
Otherwise you can use a decompiler as mentioned in adarshr's answer:
Use JD GUI. Open the application, drag
and drop your JAR file into it.
I know it's an old question Still thought it would help someone
1) Go to your jar file's folder.
2) change it's extension to .zip.
3) You are good to go and can easily extract it by just double clicking it.
Note: I tested this in MAC, it works. Hopefully it will work on windows too.
Do the following on your linux box where java works (if u like the terminal way of doing things)
cd ~
mkdir decompiled_code && cd decompiled_code
// download jar procyon from https://drive.google.com/file/d/1yC2gJhmLoyE8royCph5dLEncgkNZXj58/view?usp=sharing
java -jar procyon-decompiler-0.5.36.jar /Path/to/your/jar -o .
NOTE : as #Richard commented "this may be illegal depending on whether you own the copyright to the jar, the country you live in and your purpose for doing it."
Steps to get sources of a jar file as a zip :
Download JD-GUI from http://java-decompiler.github.io/ and save it
at any location on your system.
Drag and drop the jar or open .jar file for which you want the
sources on the JD.
Java Decompiler will open with all the package structure in a tree
format.
Click on File menu and select save jar sources. It will save
the sources as a zip with the same name as the jar.
Example:-
We can use Eclipse IDE for Java EE Developers as well for update/extract code if require.
From eclipse chose Import Jar and then select jar which you need. Follow instruction as per image below
AndroChef Java Decompiler produces very good code that you can use directly in your projects...
Above tools extract the jar. Also there are certain other tools and commands to extract the jar.
But AFAIK you cant get the java code in case code has been obfuscated.
suppose your JAR file is in C:\Documents and Settings\mmeher\Desktop\jar and the JAR file name is xx.jar, then write the below two commands in command prompt:
1> cd C:\Documents and Settings\mmeher\Desktop\jar
2> jar xf xx.jar
-Covert .jar file to .zip (In windows just change the extension)
-Unzip the .zip folder
-You will get complete .java files
I have a jar file which is used in html file as applet. I want to modify the content of the jar file and to rebuild the jar file so that the html will work fine with the new jar file. How can i do this??
I already tried unzipping using 7zip nad modified the source and created the new jar. But when i use it in html it shows some java.lang.Classnotfound error
You can unjar or rejar the classes and source files as you wish.
unjar
jar -xvf abc.jar
jar
jar cf abc.jar input-files
http://docs.oracle.com/javase/tutorial/deployment/jar/build.html
Make the changes in the code (.java files), recompile to get the .class files. Then simply replace the old .class files in the jar with the new ones. I usually use WinZip, but you can use whatever app that can handle .Zip files. It should just work.
I've faced cases where the launcher of the app uses some sort of verification and checks for this kind of changes. I had to use a new launch script. This doesn't seem to be your case though.
This is surely possible from the command line. Use the u option for jar
From the Java Tutorials:
jar uf jar-file input-file(s)
"Any files already in the archive having the same pathname as a file being added will be overwritten."
See Updating a JAR File
A brief test shows this quickly updates changes apart from trying to delete the file.
I haven't seen this answer on other threads about modifying jar files, and many, marked as duplicates, suggest there is no alternative but to remake the jar completely. Please correct if wrong.
JARs are just ZIP files, use whatever utility you like and edit away!
Disclaimer: When reverse engineering any code be sure that you are staying within the limits of the law and adhering to the license of that code.
Follow the instructions above to unpack the JAR.
Find the original source of the JAR (perhaps its on SourceForge) and download the source, modify the source, and rebuild your own JAR.
You can also decompile the class files in the JAR. This is a rather advanced process and has a lot of "gotchas".