How can I add build path items to Eclipse 3.5 using relative paths?

后端 未结 9 2058
夕颜
夕颜 2020-12-28 15:42

Eclipse 3.5 added support for relative buildpath/classpath items, yet I cannot seem to find a graphical way to add relatively pathed items. The example in new and noteworthy

相关标签:
9条回答
  • 2020-12-28 16:03

    After evaluating all responses and tinkering with Eclipse I can see no way to do this without manually editing the .classpath file.

    Marking this answer as accepted to indicate that there is no way to do this in Eclipse 3.5. Keep fingers crossed for Eclipse 3.6 or Eclipse 4.

    0 讨论(0)
  • 2020-12-28 16:04

    The actual way to do this is to import the library into your workspace so,

    Right Click in Package Explorer -> Import -> File System -> Browse (to the directory containing your jars) -> check the boxes next to the jars you want -> Browse to the workspace folder you want to import to (probably your lib folder) -> Finish

    Keep in mind this will copy the files into the lib folder so I've found that it helps keep things clean if you don't already have them in there. They will now show up in the package explorer under "lib." To add them to the classpath,

    Right click on the project -> Build Path -> configure build path... -> Add JARs -> navigate to the given project's lib folder and select the appropriate JARs -> click ok -> click finish

    This adds them to the CP with relative locations.

    If you need more help let me know

    0 讨论(0)
  • 2020-12-28 16:05

    This does not work!

    Editing the .classpath to include relative paths as per the New and Noteworthy example (path="../../lib/myjar.jar") isn't difficult, however it does not appear to work as described!

    It seems to resolve relative to the Workspace and not the specific Project as specified, which is not much use. Has anyone else found the same problem or a solution to this?

    0 讨论(0)
  • 2020-12-28 16:15

    As far as I know you currently can only achieve this by editing the .classpath file. For this to be possible through pure 'button pushing' the browse dialogs popping up after selecting 'Add External JARs...' and 'Add External Class Folder...' would need something like a check-box to specify if you want to add the relative or the absolute path. Maybe that is not hard to add, but I haven't seen it yet.

    0 讨论(0)
  • 2020-12-28 16:19

    I'm uing Helios (i.e. 3.6.x) and this is what I do to reference a lib (jar) outside of my project in a relative manner.

    1) Right click project in project explorer -> Import -> Import. 2) Select File System (Next) Use the browse button to navigate to the folder (yes, it looks like a hard-path). Select the .jar(s) to include.

    I usually append "\lib" to the project name in the "Into Folder:" option.

    Click "Advanced" and select the "Create Links in workspace" and I use the default options (both checked, and relative to PROJECT_LOC). 3) Click Finish

    Next, open up the project properties and go to Java Build Path Libraries tab and select "Add Jars..." and go to the \lib folder (from Step 2) and select the lib(s) that you need. On the Libraries tab now has "ProjectName/Lib" for the path of the lib(s).

    The project explorer will display a lib folder with your libs with a special icon. If you look in your hard drive for the lib folder, there is nothing there. So it is referring to the libs in the external path, but including them as a "project" lib.

    Right click on the jar file in the project explorer and do properties. You should see the relative path goodness.

    0 讨论(0)
  • 2020-12-28 16:19

    I've done this by adding the libraries to my project. So, create a folder under your project called "jars" and put all dependent jars in there.

    When you configure the build path afterward, everything will be relative.

    0 讨论(0)
提交回复
热议问题