Java 如何安装jar库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4393127/
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
How to install jar library?
提问by mpen
I've downloaded the ANTLR Java runtime libraries. It's a jar file. It contains "org.antlr.runtime". Where do I put it so that the Java compiler can find it? Do I need to extract it? I'm using NetBeans (for now), if relevant.
我已经下载了 ANTLR Java 运行时库。这是一个jar文件。它包含“org.antlr.runtime”。我把它放在哪里以便 Java 编译器可以找到它?我需要提取它吗?如果相关,我正在使用 NetBeans(目前)。
采纳答案by MG-Dev
For NetBeans you go to your Projects Tab and then right-click on the project you want the library added to then click Properties. Go to the Libraries bullet then on the right side click on Add JAR/Folder. No need to extract it. All you have to do is right click in the editor window and click Fix Imports.
对于 NetBeans,您转到“项目”选项卡,然后右键单击要添加库的项目,然后单击“属性”。转到库项目符号,然后在右侧单击添加 JAR/文件夹。没有必要提取它。您所要做的就是在编辑器窗口中单击鼠标右键,然后单击“修复导入”。
For use outside of NetBeans you have to add it to your Java classpath.
要在 NetBeans 之外使用,您必须将其添加到 Java 类路径中。
回答by Peter Lawrey
For java command line you need to add it to your class path however in Netbeans you just need to add it as a library. It can be anywhere. Google to find out how to do these things.
对于 java 命令行,您需要将其添加到类路径中,但是在 Netbeans 中,您只需将其添加为库。它可以在任何地方。谷歌找出如何做这些事情。
In fact in netbeans, you can just say you need this in your maven project and it will do the download of the jar and its source/documentation as required.
事实上,在 netbeans 中,您可以只说您在 Maven 项目中需要它,它会根据需要下载 jar 及其源代码/文档。
回答by richliaw
Assuming you can find your jdk folder, You can move the .jar file into the jdk\jre\lib\ext folder, where other .jar files are placed. After doing so, NetBeans should be able to run files with access to the library
假设您可以找到您的 jdk 文件夹,您可以将 .jar 文件移动到 jdk\jre\lib\ext 文件夹中,其他 .jar 文件放置在该文件夹中。这样做之后,NetBeans 应该能够运行具有库访问权限的文件