How to import external library by relative path in eclipse?

You should declare a variable (Java Build Path -> Add Variable… -> Configure Variable … -> New) to set the changing path on each system (e.g. FOO_BAR_HOME).

Than you can add the Variable to the Libraries and edit it to point to your library, like

%FOO_BAR_HOME%/lib/foobar.jar

Take a look at the existing variables for usage.

Alternative you can place the library inside the project (e.g. subfolder ‘lib’). If you add the library from this location (‘Add Jars…’ NOT ‘Add External Jars…’) it will be added by relative path.

Leave a Comment