简体   繁体   中英

Import project (jar) into Eclipse

I got a .jar file which I need to import into Eclipse. However, I don't want to have the jar as a referenced library. I need the .jar to be included like 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 place this jar also as a referenced library, it is imported but with .class files.

New Java Project -> Import -> General -> File System. Imports the .java files, but the packages are lost and are normal folders. Also, the files are somehow strange, because the "j" in the icon looks differently, and errors are not noticed (no underlining)

Importing "Existing Projects into Workspace" doesn't work at all, it says that there is no project. I also tried to import the jar as a zip after extracting it, this gives me the -java files, but it destroys the packages.

Does anyone know how to import this correctly?

I have managed it this way: New Java Project -> Java settings -> Source -> Link source (Source folder). There I added my decompiled jar and it was imported correctly :)

You can also create a new Java Project and then do File -> Import -> General -> Archive File. This will save you a step of unzipping your jar and adding as a linked source folder.

You cannot import a jar that way, unless it has the source code packed in the jar. If you really need the source code, you'll have to find an archive somewhere. But of course, not everyone is willing to share his source...

I tried the below and it worked.

  1. Create a New Java Project
  2. Goto File > Import > General > Archive File
  3. Select the required Archive file( .jar in this case) from your local system.
  4. Select the project you created in Step 1 and click Ok

This will save you a step of unzipping your jar but if there are .class files, eclipse won't convert them to .java files. This has to be done seperately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM