Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the content of a .jar file as project in Eclipse?

Tags:

java

jar

i received a .jar file and want to use the content of the file as an Eclipse project NOT

in an Eclipse project

I have tried to extract the .jar file, but eclipse doesn't reconize it as java project. The Jar file contains .class and .java files.

I already tried this way:

1-extract the JAR-file
2-create an new project in eclipse
3-right click on that project
4-import
5-file system

But i didn't work!

How can i proceed?

Thank you!

like image 823
lisa Avatar asked Nov 08 '13 10:11

lisa


2 Answers

if you want to modify the code, this works if the JAR contains the source-files:

  1. extract the JAR-file
  2. create an new project in eclipse
  3. show the project (+)
  4. right click on the "src" folder
  5. import
  6. file system
  7. choose the folder you want to import
  8. check it in the left panel

if you just want to use the classes in the JAR-file

  1. rigth click on the project
  2. build path.
  3. libraries and click on Add external JARS.

if you want to modify the code of the JAR but it does not contain the source files, you need to decompile the class-files.

like image 149
Philipp Sander Avatar answered Oct 26 '22 23:10

Philipp Sander


If you need the code, Simply:

1) Right click on your existing src folder (or a new folder you can create if you want)

2) Select "Import"

3) Under "General" select "Archive File"

4) Browse for your jar file. You will then be able to see all of the jar's contents.

5) Click finish and you are done.

like image 21
mikehoncho Avatar answered Oct 27 '22 00:10

mikehoncho