Search code examples
javaeclipsebuildpath

Java Eclipse Build Path


Hi i write a Java Swing GUI that includes alot of .jar files.

I have add alot of .jar files to my Buildpath. If now my friend trys to run the programm he got my Buildpath and they are wrong on his pc.

Is there a possible way to set the Buildpath so my friend don't have to set them again?

for example at the moment one buildpath is like this: home/usr/bonzai/oad/xxx.jar

my programm that is executed is in the folder bonzai. so i want to set the path like this: ./oad/xxx.jar

So the programm knows go into the folder oad, that is in the same folder, then take xxx.jar.

Hope you understand what i want to do :-)

mfg Christoph


Solution

  • I had this problem with using a project on Windows and Linux.

    1. Go to Window->Preferences->Java->Build Path->Classpath Variables
    2. Click "New", pick a name, like MY_PROJECT, and point to the project folder.

    When you include jar files, you do it a different way.

    1. Project Properties->Java Build Path->Libraries (where you add jar files)
    2. To add, click "Add Variable"
    3. Select the MY_PROJECT variable you made and click "Extend". Find the resource and add it to your project.

    Now when anyone wants to use your project, they just have to do step 1 and 2. and point the MY_PROJECT classpath variable to where ever the folder is. It can be anywhere. As long as the structure inside is the same, everything works.

    This is how I share .project files with GIT. You can clone the project anywhere but everything works.