All, I have a jar file. and I know it is built from a swing project. Becuase I already view some source code of class files of the jar. I want to know if there exists any tools help to convert the jar back to the source project in the eclipse? Thanks.
http://jd.benow.ca
Drag and drop jar file into JD GUI decompiler
select File-> Save all sources
7zip will allow you to view the contents of the jar, including source files if they are there. Lots of decompilers exist to decompile the class files. My favorite is jd-gui (http://jd.benow.ca/).
You can also add a jar in Eclipse by right-clicking on the Project → Build Path → Configure Build Path. Uthen under tje Libraries tab, click Add Jars or Add External JARs and select the jar file. Alternatively you can add a lib directory to your project and put a copy of the jar there.
But as far as converting a jar file into an eclipse project, you could extract the files with 7zip or other tool, then import them into a new eclipse project.
Related
I am using NetBeans 8.0.1 compress jar option in properties to make a jar file of my project.
I want the jar file to include some external jar files in the libraries. However, my exported jar file does not have external libraries, which I want to include. How to add external libraries to a jar file?
edit [Wrong]
I'm not really sure what you did, but usually libraries have JAR-files which you add using the Properties->Libraries->Add Jar/Folder button.
When coding, you're able to use the library. When you build your project the JAR-libraries will be included in your new JAR. I've only used external libraries once, for reference.
I have a library called Snakeyaml.jar, and I want to add it to my eclipse project, so it will be included in my jar, when I export my project. So far, I only see ways to add an "External Jar" which only adds a jar library to the buildpath, and does NOT include it in the program when being exported! How can I do it, and do I need any plugins for that? Please help!
Thanks.
Adding the jar to your build path is for compilation and runtime, but from eclipse only. A common misconception is that jar files can be added into other jar files, which will never work. What you probably want is extract your library jar into your exported jar. To achieve this:
File - Export
Expand Java node and select Runnable JAR File
In the library handling section, select Extract required libraries into generated JAR
Reference:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-export-runnable-jar.htm
While exporting you can chose the File->Export->Runnable Jar Option . Then use the selection like below screen i.e Extract required libraries into generated jar
Okay, so I understand what you are actually asking! You want the Snakeyaml.jar file inside of your exported jar file, and for your program to use its libraries.
To do so, drag and drop the Snakeyaml.jar file into your src folder in eclipse.
Then, go to build path, and instead of looking for external jars for your buildpath, choose to use the jar file that is already in your src folder in eclipse. Once you do that, you should export it and pick to "Extract required libraries into jar file" or something like that, and everything should work well! You will notice upon opening the exported jar file with a tool like Winrar, that the jar you had in your src folder is not there, but the packages of the jar are actually side by side with yours.
I have a jar file of an existing project. I want to write Junit test cases for each class in that project. To do that, I want to import that jar file as a java project in Eclipse so I can start new development of the same code. Is it possible to import a .jar file the same way we did for a .war file, and start developing the web project? If so, how?
A .jar file is just a .zip file containing all the class files of your java project. If the source files are included in the .jar file, you can unzip it and add them in eclipse. If they aren't, then you can't do what you want to do.
If you have source files in your jar i.e .java files along with your .class files, then rename your jar to zip and unzip the files. These java files can now be manually copied under src folder in eclipse.
Once your modifications are done, the new jar with your modifications can be created like this -> Right click on project ->export->Java->Jar option in eclipse. Or you can use ANT/Maven or similar build tool.
I'm rather new to java and eclipse, and I would like to get jar files from this github project:
https://github.com/nikkiii/omegle-api-java
I've tried doing so in eclipse, but I can't import the project as a java project, and (I think) for this reason I am not able to use the Export feature to obtain jar files for the project. What is the easiest/best way to go about this?
Thanks
This is the easiest way, assuming you dowloaded the zip file containg the .java source files from github:
Unzip the zip file into a folder in your Eclipse workspace, say omegle-api-java-master.
In Eclipse, select New->Java Project and name it omegle-api-java-master. Eclipse will create a project from the source in your workspace, and set it up with a java builder.
Import any required jars to get it to compile (for example the project page states you need https://github.com/douglascrockford/JSON-java). You can extract that in your workspace in the same way and then import it into your Omegle project by right clicking on the Omegle project, selecting Properties, going to Java Build Path, selecting the Projects tab, and clicking the Add button.
Once everything is compiling, right click on the Omegle project, select Export -> Java -> JAR file, which will create your jar file for you.
I assume that you have an Android library (downloaded a GitHub repository of the library) and found that it doesn't contain pom.xml. If you have this file, see How to Create a jar file from github project.
Open a folder of the library and add local.properties file with a path to your Android SDK (for instance, sdk.dir=D\:\\Android\\SDK). Otherwise you can see an error: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
In command prompt (cmd.exe) run gradlew build. If it will throw Android exceptions, maybe you should switch to master branch of the library and build again.
If everything was normal see subfolders and look for build\libs folders inside. There you can find jar-files.
I have create a simple program using Eclipse 4.1.. I wanted to build or deploy my project into a .jar. I also added external libraries in my project. I wanted the output same as in Netbeans with the .jar file and lib folder in the dist folder, but there should be also a folder named help and lang.. How can I do this with eclipse?!
Follow the steps provided here.
Or if you don't want to complex things up, select Runnable JAR file instead of JAR file set the directory where the .jar is to be written then click Finish.
Eclipse will create the [Project Name]_lib directory for the external libraries included in the project.