简体   繁体   中英

Need to add the javax.mail package to my eclipse

I want to create a basic java application where I send and receive an email , but my Eclipse doesn't recognize the javax.mail package which I need for the code.

I've downloaded the package, but I can't figure out how to add it to my Eclipse.

I also would prefer that it gets added to my Eclipse workspace and not just to the one project that I am doing, as I will need the package later for other projects.

How do I install the package? I don't know how to properly use things like class paths and command prompts etc, so I need a step by step help if it requires that.

If that's really what you want to do, go to Preferences -> Java -> Build Path -> User Libraries .

Then press new... give it a name and add the jars , which should be ideally located in an appropriate place that makes sense to you and especially not in the JRE directory.


Then you can use those libraries in any new project. For that go to properties of the project, Java Build Path and add the libraries in the (surprise) Libraries tab.


But I think you would be better off using Maven , Gradle or any other build tool in your projects. However if a library is not publicly available in a repository, and you must download the jars, then this a reasonable option.


Here are some images illustrating the process:

1. How to add new libraries to Eclipse

用于添加用户库的Eclipse对话框

2. Edit library settings (adding source, javadoc and so on)

用于更改库设置的Eclipse对话框

3. Add your user library to a project

用于将库添加到项目的Eclipse对话框

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM