CanCeylan
CanCeylan

Reputation: 3010

How to import an external jar file and export project as a file system in Eclipse

I added an external jar file into my eclipse project from the properties>libraries in my project. Then I export my project as a file system, to make runnable for every computer. However after I import to project in eclipse, jar file refers to the my computers path thats why it does not work.

How should I solve this ?

Thanks

Upvotes: 1

Views: 1045

Answers (1)

david a.
david a.

Reputation: 5291

Define a class path variable and refer to the JAR using a variable in the class path of your project. Each programmer can then set the variable according to theirs environment. Variables can be set in Window -> Preferences -> Java -> Classpath Variables and used by pressing Add Variable... in Java Build Path editor of your project. When adding a variable to classpath, you can even press Extend... and "extend" your variable with a suffix - i.e. have the variable contain a folder name and suffix it with a fixed file name.

Some more obvious options:

  • Copy the JAR inside your project, then export it.
  • Agree on a common workspace structure and use a relative path to refer to the JAR.
  • Use a dependency management tool (e.g. Maven).

Upvotes: 2

Related Questions