Is it possible to reference the Java source path using a variable in Eclipse

Background

I am using the Eclipse 4.2 (Juno) release to create a plugin for a Java application. The source code and classes for my plugin are in the project workspace. For various reasons, the jar application and its source code are supported outside the eclipse workspace, and the jar application is created by another build engine.

This is not a problem, because I reference the jar file of the application file in my project using the drag-and-drop function and the “Link to files” parameter instructing it to “Create link location relative to: MYDEV , where MYDEV is the associated resource variable that I created for each installation Eclipse: This allows me to use the same eclipse project on multiple machines, where the path to the application bank changes, but always matches MYDEV.

However, I cannot find a way to link the source code of the application with this bank if I do not use the absolute path. I want to access the source of the application for debugging purposes.

Question

In Eclipse, how can I attach a java source to a specified jar in a way that allows the project to be used on multiple installations, where the link source code was moved?

+4
source share
3 answers

If the source is outside of proyect, then there is no access to it without an absolute path.

The best solution is to use a symbolic link inside the eclipse project directory in the actual source folder; eclipse will not notice that the source is outside the project directory, and everything will work fine, without having to reinstall the source.

+1
source

This is the only way I was able to do what you offer (I don't know if there are better ways).

A jar file package that contains the source code for the jar file. Put it inside your project in a folder (you don't need to add it to your class path)

In the eclipse project, right-click on the JAR file and go to “properties” and then to “Java Source Application”. From there, select "Workspace" and select the jar file with the source code that we added from the above step.

Thus, the source binding path will always be related to the project. Thus, if you transfer the project via SVN, GIT or something else, the source will always be available, and it will work if the user runs eclipse on Windows or Linux.

I had a similar problem with you, when absolute paths were a problem for people using different OSs, and even without using mapped drives through Samba, it helped a lot.

Hope this helps.

0
source

The way I solved this problem is to use the library defined for use in eclipse. Here are the steps you can use to solve this problem.

  • Create a simple project in eclipse in a directory that contains banks and source code files.

  • Define a java user library, add banks to the user library, and for each bank in the library, specify the source location. If the source files are in the project, which is located in the workspace, the path will refer to the workspace folder.

  • Export user library as XML file

When another use wants to set up the eclipse workspace with the same parameter as yours, they will do two things.

  • Import a project containing banks and sources into the workspace.

  • Import the user library into your working folder.

0
source

All Articles