Java Build Path - Add External JARs' and Add Variable
Asked Answered
E

1

3

What is the difference between Java Build Path - Add External JARs Button and Add Variable Button Functionality, Why its required. Please explain in detail.

Edwards answered 28/4, 2010 at 12:59 Comment(0)
T
5

Both can be used to achieve the same thing: add a JAR to your build path.

Suppose you have a project P1 that wants to use a JAR installed by supplier S1, which happens to be located at C:\S1\aproject\jars\Useful.jar

Client Add External JARs, navigate, select, and we're done.

But, consider these cases.

1). Suppose you have several projects that all want to use that same JAR? You end up repeating that for projects P1-PN. Gets dull. What's worse, suppose you install a new version of S1's stack, now you need to update all those project's build paths to reference

C:\S1\aproject-**v2**\jars\Useful.jar

And what's worse, if you miss one then you are running two versions of the JAR that may be really bad!

2). You share a project with a colleage who happens to have S1 product installed in a different location. They now need to amend the project to point to

 E:\MyFavouriteThings\S1\aproject\jars\Useful.jar

And if you are using an SCM you may tread on each others toes.

So:

Instead Add Variable allows you to define a Workspace variable (ie. specific to your environment) which can then be used to reference that JAR

 $(S1_JARS)\\Useful.jar

Now you a single place to update to a new version of S1, and each developer can set his own value for S1_JARs.

I would recommend using Variables for non-trivial development scenarios.

Transship answered 28/4, 2010 at 13:21 Comment(3)
Interesting, with our Java development we currently share the most recent JARs across a network share, which means you can break everyone's builds by updating JARs without checking in the code (which happens when you are working across several related projects)Fibrilliform
@Fibrilliform presumably you could have versioning in the share, using various subdirectories, this would put the onus on the individual developer to upodate their classpath variable. Personally I'd prefer to do this than inadvertantly have broken builds.Transship
possibly, I've only recently joined the team, so still getting to grips with the set up and how the various directories relate to their dev processFibrilliform

© 2022 - 2024 — McMap. All rights reserved.