Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import source code into Eclipse from a jar file?

Tags:

java

eclipse

jar

I got a jar file that is packaged with source code in it. I want to load it as a top-level project and start working on the source code. How can I do that in Eclipse?

For example: if I have helloworld.jar, when I import this jar. I want to have the project name as helloworld, with all the packages and src inside it.

I do not want that code on build path.but on my IDE to work with.

like image 577
eagertoLearn Avatar asked Jul 07 '14 19:07

eagertoLearn


People also ask

Can we extract source code from jar file?

You can always extract the source files (Java files) of a jar file into a zip. 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.


2 Answers

Create a directory named "helloworld" and unpack the JAR into that directory:

mkdir helloworld
cd helloworld
jar xvf ../helloworld.jar

You can then create a project from existing sources and start operating on that. I don't think Eclipse will let you create a project and change files directly in the JAR.

like image 130
Erik Gillespie Avatar answered Oct 03 '22 09:10

Erik Gillespie


@eagertoLearn Yes. Eclipse does this in a very easy way than suggest by @Erik Gillespie.

Use Import from archive file feature in eclipse. Refer this post https://stackoverflow.com/a/11983201/1391924

Supported archive file types:

  • *.jar
  • *.zip
  • *.tar
  • *.tar.gz
  • *tgz
like image 33
Chandrayya G K Avatar answered Oct 03 '22 09:10

Chandrayya G K