Search code examples
javajarjakarta-maillibrariesbluej

How to add a .jar file to a BlueJ project?


I am developing a Java console application and using the mail code to send an email when a user purchases a product. For that purpose, I am using mail.jar and activation.jar files. But in BlueJ, I can't find any option to import a jar file. Following is the screenshot of it.

enter image description here

Should I update my BlueJ or what can I do to add jar files to my project?

Thank you


Solution

  • I am not sure what your problem actually is, but here is an overview that hopefully helps:

    When you want to use 3rd party JARs for your project, you need to do three things:

    • your IDE must know that x.jar will be used by the project, that is where you add an external jar in bluej, see here
    • in your source code for your classes, you have to import any 3rd party class, so that the compiler knows you want to use it
    • later, when "shipping" your project to other people, you have to include the jar files, too. And of course, your class path setup must be correct.