Search code examples
javaimportjakarta-mailibm-cloudwebsphere-liberty

calling javamail api from Liberty server on bluemix


Last week I had a classpath issue with my javamail.jar. link

I found that on Bluemix, the liberty server I am deploying to contains a javamail api (java ee server), and that is where my classpath issue is coming from. However, if I am to remove the javamail-1.5.5.jar from my classpath, I receive errors stating that it cannot find other things (the first being: javax.mail.search.SearchTerm). I cannot remove MY imported javamail fully due to this error.

I have three questions:

  1. Where is the javamail api on the websphere server for bluemix located, so that I could call the import directly, instead of my own .jar

  2. What is the version of javamail that Liberty has on it.

  3. Can you see any way of solving this better?

I can put some of my code on here as well if that would be helpful, however its a pretty standard email reader.

Thanks so much for your time!

-Tony


Solution

  • When you're compiling your application you need access to the JavaMail classes, but when you package your application you don't want to include those classes. Depending on what build system you're using, there are different ways to do this. In Maven you can use a "provided" dependency, for example.