[英]Eclipse - External jars need to be manually added
I had a question that was answered with adding jfxrt.jar to standard Eclipse build path . 我有一个问题,可以通过将jfxrt.jar添加到标准Eclipse构建路径来解决 。
I followed the suggestion, adding the jfxft.jar as an External Jar on the jdk1.7.0_10.jdk JRE i have installed (under Eclipse > Preferences > Java > Installed JREs). 我遵循了建议,将jfxft.jar作为外部Jar添加到我已安装的jdk1.7.0_10.jdk JRE上(在Eclipse> Preferences> Java> Installed JRE下)。
But when I import "javafx.application.Application" 但是当我导入“ javafx.application.Application”时
It errors with: 出现以下错误:
Access Restriction: The type Application is not accessible due to restriction on required library /Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/jre/lib/jfxrt.jar 访问限制:由于必需的库/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/jre/lib/jfxrt.jar受限制,因此无法访问应用程序类型
There are posts on this such as Access restriction: Is not accessible due to restriction on required library ..\\jre\\lib\\rt.jar 关于此的帖子,例如访问限制:由于对所需库.. \\ jre \\ lib \\ rt.jar的限制而无法访问
I can fix this possibly by the suggestions in that thread (though I'm not convinced they are good solutions). 我可以通过该线程中的建议来解决此问题(尽管我不相信它们是好的解决方案)。
Or I found a better solution of adding the External Jar directly to the project: - go to the JRE and remove the External Jar as setup above - Open project properties and go to Java Build Path - Go to Libraries tab - Add External JARS... and choose exactly the same jfxrt.jar 或者,我找到了将外部Jar直接添加到项目中的更好的解决方案:-转到JRE并按照上面的设置删除外部Jar-打开项目属性并转到Java Build Path-转到“库”选项卡-添加外部JARS。然后选择完全相同的jfxrt.jar
No access restrictions now! 现在没有访问限制!
Why does it work one way but not the other? 为什么它会以一种方式起作用,而不能以另一种方式起作用? The advantage of adding directly to the JRE configuration is that it only needs to be done once.
直接添加到JRE配置的优点是只需执行一次即可。
Thanks, 谢谢,
Hank 汉克
I would not recommend adding JARs to the JRE configuration like that, it's just too easy to forget they are there and that can lead to confusing behavior if you don't expect that particular JAR to be on the build path for a particular project. 我不建议像这样将JAR添加到JRE配置中,太容易忘记它们了,如果您不希望特定项目的构建路径上包含特定JAR,可能会导致混乱的行为。 Also, what happens if one project wants to use a different version of the library?
另外,如果一个项目想要使用该库的其他版本会怎样?
There are at least 2 other options that I would consider: 我还会考虑至少2个其他选项:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.