Java构建路径 - 添加外部JAR“和添加变量 [英] Java Build Path - Add External JARs' and Add Variable

查看:523
本文介绍了Java构建路径 - 添加外部JAR“和添加变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java Build Path - 添加外部JAR按钮和添加变量按钮功能有什么区别,
为什么它是必需的。请详细解释。

解决方案

两者都可以用来达到同样的效果: p>

假设您有一个项目P1想要使用供应商S1安装的JAR,它恰好位于C:\S1\aproject\jars\Useful .jar



客户添加外部JAR,导航,选择,我们完成了。



这些情况。



1)。假设你有几个项目都想使用同一个JAR?你最终重复了项目P1-PN。得到沉闷。更糟糕的是,假设您安装了新版本的S1堆栈,现在您需要更新所有这些项目的构建路径以参考

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

更糟糕的是,如果你错过了一个,那么你运行的两个版本的JAR可能是非常糟糕!



2)。您与大学共享一个项目,他们恰好将S1产品安装在不同的位置。他们现在需要修改项目以指向

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

如果你使用的是SCM,你可以踏上彼此的脚趾。



所以:



而添加变量允许你定义一个 Workspace 变量到您的环境),然后可以用于引用该JAR

  $(S1_JARS)\\Useful.jar 

现在你有一个地方可以更新到新版本的S1,每个开发人员可以为自己的S1_JAR。



我建议您在非平凡的开发场景中使用变量。


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

解决方案

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.

这篇关于Java构建路径 - 添加外部JAR“和添加变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆