将 Jars 添加到 Eclipse Helios、Mac OSX 中的用户库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4717932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add Jars to User LIbraries in Eclipse Helios, Mac OSX
提问by dfdumaresq
I've created a new Java project (testProject) and begin to add jars to a user library, but I'm getting project errors after adding jars to a "User Library"
我创建了一个新的 Java 项目 (testProject) 并开始向用户库添加 jar,但是在将 jar 添加到“用户库”后出现项目错误
Here's what I'm doing:Create the User Library
这是我在做什么:创建用户库
- Right mouse click the project and click Properties
- Click Add Library..., select User Library, and click Next
- Click button, User Libraries...
- Click New... and give it a name: mule; click OK.
- Select mule and click Add JARs...
- Add a jar (e.g. I've added two, one from the root project, log4j.jar, and another from /opt/mule/lib)
- Click OK
- Click Finish
- 鼠标右键单击项目,然后单击属性
- 单击添加库...,选择用户库,然后单击下一步
- 单击按钮,用户库...
- 单击 New... 并为其命名:mule;单击确定。
- 选择 mule 并单击 Add JARs...
- 添加一个 jar(例如,我添加了两个,一个来自根项目 log4j.jar,另一个来自 /opt/mule/lib)
- 单击确定
- 单击完成
Now I'm seeing a red x show on the mule library. 1. Click Edit, and click User Libraries 2. The message on each jar says the library is missing, and it seems to be losing the actual path.
现在我在 mule 库上看到了一个红色的 x 显示。1. 单击编辑,然后单击用户库 2. 每个 jar 上的消息说库丢失,并且似乎丢失了实际路径。
See attached image:
见附图:
I'm running On a Mac OSX 10.5.8, running Java openjdk version "1.6.0-internal" OpenJDK Runtime Environment (build 1.6.0-internal-landonf_17_may_2009_13_58-b00) OpenJDK Client VM (build 11.0-b17, mixed mode)
我在 Mac OSX 10.5.8 上运行 Java openjdk 版本“1.6.0-internal”OpenJDK 运行时环境(build 1.6.0-internal-landonf_17_may_2009_13_58-b00)OpenJDK Client VM(build 11.0-b17,混合模式)
This doesn't seem to be a problem on a Vista PC, running Eclipse on Java 1.6.0_16. (Or under Ubuntu).
这在 Vista PC 上似乎不是问题,在 Java 1.6.0_16 上运行 Eclipse。(或在 Ubuntu 下)。
Is anyone else seeing this?
还有人看到这个吗?
采纳答案by Konstantin Komissarchik
There have been a number of problems reported by people trying to run Eclipse on Open JDK. Plus it looks like you are using some sort of pre-production build of it. The first thing I'd do is to try running Eclipse with JDK that comes with Mac OSX.
尝试在 Open JDK 上运行 Eclipse 的人们报告了许多问题。另外,您似乎正在使用它的某种预生产版本。我要做的第一件事是尝试使用 Mac OSX 附带的 JDK 运行 Eclipse。
回答by rajah9
I have had a similar problem in Eclipse Indigo SR2 on a Windows XP workstation. It ran perfectly for a long time until it broke and displayed the behavior that the OP has observed.
我在 Windows XP 工作站上的 Eclipse Indigo SR2 中遇到了类似的问题。它完美运行了很长时间,直到它损坏并显示 OP 观察到的行为。
I have found out more what causes the problem and have found a workaround.
我发现了更多导致问题的原因并找到了解决方法。
The problem is caused when I choose Preferences -> Java -> Build Path -> User Libraries | Add JARS... and add a new jar file. What happens is that although the user library is given an absolute path (C:\Documents and Settings\a23456\box_corefx\1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar
) it only stores a relative path (\1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar
). This relative path is what makes it say "missing."
问题是当我选择 Preferences -> Java -> Build Path -> User Libraries | 时引起的。添加 JARS... 并添加一个新的 jar 文件。发生的情况是,尽管用户库被赋予了绝对路径 ( C:\Documents and Settings\a23456\box_corefx\1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar
),但它只存储了相对路径 ( \1box-corefx\box-build\target\deployment\weblogic\APP-INF\lib\antlr-2.7.6.jar
)。这个相对路径使它说“失踪”。
The workaround is to export a good user library and massage the jars so that it has entries like:
解决方法是导出一个好的用户库并按摩罐子,使其具有如下条目:
<archive path="C:/Documents and Settings/a23456/box_corefx/1box-corefx/box-build/target/deployment/weblogic/APP-INF/lib/antlr-2.7.6.jar"/>
Then import the new user library.
然后导入新的用户库。