21

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.

Also, do I need other setup in order to use Java Mail API?

1
  • 1
    Life is so much simpler if you use maven. A few lines of xml and you'll have your jar. Jan 12, 2014 at 17:34

2 Answers 2

38

1) You need to create a Project in 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.2.) From the File menu just choose Project structure.

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.

Note: The JAR you need to have downloaded first on your local machine.

Here is a screenshot, with added one JAR to a project I just created.

enter image description here

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/

4
  • Thank you for the screenshot. It is now successfully added. I guess I have typo on my question. I was gonna say "JavaMail API", not "JavaAPI". Sorry for the typo! Jan 10, 2014 at 19:09
  • You can help me out if you know about JavaMail API. Jan 10, 2014 at 19:11
  • @user3014926 Well, if you want to send out emails do a Google search for "SMTP JavaMail example", if you want to receive emails do a Google search for e.g. "POP3 JavaMail example". You will find lots of examples. Jan 10, 2014 at 19:13
  • Whats the difference between adding jars to Libraries versus adding it to Modules Jul 17, 2015 at 18:25
3

You can go to 'Project structure' with this short key 'Ctrl+Alt+Shift+s'

and in Library you can add your jar files

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.