Java 将 jar 文件导入 IntelliJ Idea?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21051991/
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
Importing jar file into IntelliJ Idea?
提问by user3014926
I want to use methods in Java Mail API, so I am trying to import its jar into my project on IntelliJ IDEA. How do I import or download this new jar? I am not new to IntelliJ IDEA, but haven't imported new jar in two months now.
我想使用 Java Mail API 中的方法,所以我试图将它的 jar 导入到我在 IntelliJ IDEA 上的项目中。如何导入或下载这个新 jar?我对 IntelliJ IDEA 并不陌生,但现在已经两个月没有导入新的 jar 了。
Also, do I need other setup in order to use Java Mail API?
另外,我是否需要其他设置才能使用 Java Mail API?
采纳答案by peter.petrov
1) You need to create a Project in IntelliJ IDEA.
1) 您需要在 IntelliJ IDEA 中创建一个项目。
Now you have two options.
现在你有两个选择。
2.1.) Open the Project view in the IDE. Then right
click on your Project and do Open Module Settings (or press F4).
2.1.) 在 IDE 中打开项目视图。然后右键
单击您的项目并打开模块设置(或按 F4)。
2.2.) From the File menu just choose Project structure.
2.2.) 从文件菜单中选择项目结构。
3) Then go to Libraries on the left side. Then click the + sign (add new library).
Then locate your JAR and select it, this will import it as a library.
3)然后去左边的图书馆。然后单击 + 号(添加新库)。
然后找到您的 JAR 并选择它,这会将其作为库导入。
Note: The JAR you need to have downloaded first on your local machine.
注意:您需要先在本地计算机上下载 JAR。
Here is a screenshot, with added one JAR to a project I just created.
这是一个屏幕截图,在我刚刚创建的项目中添加了一个 JAR。
To make an example that works you'll need some mail servers.
要制作一个有效的示例,您需要一些邮件服务器。
See for example here.
参见这里的例子。
http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/
http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/
回答by Vahid
You can go to 'Project structure' with this short key 'Ctrl+Alt+Shift+s'
您可以使用此快捷键“Ctrl+Alt+Shift+s”转到“项目结构”
and in Library you can add your jar files
在库中,您可以添加 jar 文件