Import project (jar) into Eclipse

I got a .jar file that I need to import into Eclipse. However, I do not want to have a jar as a reference library. I need the .jar to be included as a β€œnormal” project with packages (!) And .java files.

I tried to do the following: New Java project -> Import -> General -> Archive file. In this case, when I put this jar also as a reference library, it is imported, but with .class files.

New Java project -> Import -> General -> File System. Imports .java files, but packages are lost and are normal folders. In addition, the files are somehow strange, because the β€œj” in the icon looks different and no errors are noticed (no underline)

The import "Existing projects into the workspace" does not work at all, he says that there is no project. I also tried importing jar as zip after extracting it, it gives me -java files, but it destroys the packages.

Does anyone know how to import it correctly?

+6
source share
4 answers

I succeeded: New Java project β†’ Java settings β†’ Source β†’ Link source (Source folder). There I added a decompiled jar and it was imported correctly :)

+9
source

You can also create a new Java project and then do File β†’ Import β†’ General β†’ Archive File. This saves you the need to unzip your jar and add it as a linked source folder.

+6
source

You cannot import the jar in this way if it does not have the source code packaged in the jar. If you really need the source code, you need to find the archive somewhere. But, of course, not everyone is ready to share their source ...

+3
source

I tried below and it worked.

  • Create a New Java Project
  • Go to File > Import > General > Archive File
  • Select the desired archive file ( .jar in this case) from the local system.
  • Select the project created in step 1 and click Ok

This saves you from having to unzip the jar, but if you have .class files, eclipse will not convert them to .java files. This must be done separately.

+2
source

All Articles