5

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
eagertoLearn
  • 9,772
  • 23
  • 80
  • 122

4 Answers4

3

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.

Erik Gillespie
  • 3,929
  • 2
  • 31
  • 48
  • Thanks. I was struggling with ways to see if eclipse automatically does it. but nevertheless, what you suggested is not very tedious – eagertoLearn Jul 07 '14 at 20:04
3

@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
Community
  • 1
  • 1
Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
0

Right click on the .jar and choose open with -> winrar (or another archiver) and then click extract.

From there you can import the folder in Eclipse as a new project.

Nicolas
  • 1,125
  • 1
  • 15
  • 31
0

I was able to import the jar file contents using the following steps:

  1. Create a new java project
  2. Import jar file using file>import>general>archive file option
  3. Move the folder containing source code into the src folder using drag and drop
  4. Run the class containing the main method
Tibin Thomas
  • 1,365
  • 2
  • 16
  • 25