Hi there.
My name is Diana Thomas. I am a junior Java Developer who needs a bit of help.

I am trying to automatically send e-mails from my Java servlets.
I am using JDeveloper with Oracle 10g.

I have got the mail.jar and the activation.jar from the JavaMail and JavaBeans Activation Framework respectivley.
I have created a "classpath" enviroment variable in the advanced functions in "My Computer" and added these jar files to the classpath.

I don't think this is enough for the compiler to see these classes.
I am sure I need to add these paths somewhere in JDeveloper(Oracle).

Could anyone possibly help me with this?????????????

Many Thanks

Diana Thomas ;)

Dani AI

Generated

A short, practical summary and next steps.

As pointed out, there are both global (server/JVM) and application-level locations for libraries, and confirmed that adding the jars into the IDE fixed compilation. The most portable, least error-prone choice for a servlet is to make the JavaMail/JAF jars part of the web application so they travel with the WAR. That guarantees the servlet classloader sees the classes at runtime regardless of which servlet container or server is used.

How to handle this in JDeveloper and at deployment:

  • Add the JavaMail and Activation jars to the web project’s compile libraries/classpath inside the IDE so code compiles.
  • Make sure your project’s deployment profile packages those libraries into WEB-INF/lib of the WAR. After building, open the WAR (it is a zip file) and confirm the jars appear under WEB-INF/lib.
  • If you need a single centrally managed copy for many apps, put the jars in the application server’s shared library area instead — but do this intentionally, and avoid having the same library both in WEB-INF/lib and in the server libs at the same time.

Troubleshooting tips:

  • If you see ClassNotFoundException or NoClassDefFoundError for javax.mail.*, check the WAR to confirm jars are present.
  • If odd ClassCastException or linkage errors appear, look for duplicate/conflicting versions between the webapp and server.
  • Inspect server logs and the exploded application directory on the server to verify which jars are actually being loaded.

Minimal sanity-check snippet (JavaMail 1.x style):

Properties props = new Properties();
props.put("mail.smtp.host", "smtp.example.com");
Session session = Session.getInstance(props);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("sender@example.com"));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("recipient@example.com", false));
msg.setSubject("Test");
msg.setText("Hello");
Transport.send(msg);

Note: avoid relying on a global CLASSPATH environment variable or the JVM extension area unless you understand the implications, because those approaches affect every application on the server and can lead to version conflicts.

Recommended Answers

All 2 Replies

Hi,

You don't have to modify the classpath if you put those jar files in your JAVA_JRE_DIRECTORY/ lib/ext. What Servlet server are you running? There are also standard locations in servlet servers to put .jar files in.

Ed

Hi there.
My name is Diana Thomas. I am a junior Java Developer who needs a bit of help.

I am trying to automatically send e-mails from my Java servlets.
I am using JDeveloper with Oracle 10g.

I have got the mail.jar and the activation.jar from the JavaMail and JavaBeans Activation Framework respectivley.
I have created a "classpath" enviroment variable in the advanced functions in "My Computer" and added these jar files to the classpath.

I don't think this is enough for the compiler to see these classes.
I am sure I need to add these paths somewhere in JDeveloper(Oracle).

Could anyone possibly help me with this?????????????

Many Thanks

Diana Thomas ;)

Hi cosi.
Thanks so much for your help and time. I really appriciate it.
What I've done is put the path in the "System Libraries" option in JDeveloper.
It seems to be working fine. Thanks for the info on the "Java_JRE_DIRECTORY/lib/ext" file. I will put my paths there in future!

Thanks again

Diana Thomas

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.