Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaMail Error

Status
Not open for further replies.

cpope

Programmer
Jul 7, 2000
58
US
I am trying to get JavaMail to work, it compiles fine, but when I try and run the application, it causes this error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Session
at testEmail.main(testEmail.java:15)

Here is a partial code clip:
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

public class testEmail
{

public static void main(String[] args)
{
try
{
Properties props = new Properties();
props.put("mail.host","");

//ERROR HERE
Session mailConnection = Session.getInstance(props,null);

}
catch(Exception e)
{
System.out.println("Exception Occurred");
e.printStackTrace();
}
}
}

Has anyone ever received this error?
 
The error occurred because the JAR files had to be located both in the compiler JRE and the JRE of the computer located in Program Files\JavaSoft\JRE
 
The error occurred because the JAR files had to be located both in the compiler JRE\lib\ext and the JRE of the computer located in Program Files\JavaSoft\JRE\1.3.1\lib\ext
 
Hi cpope,
I don't think the jar files has to be located in the places that you've mentioned. Let them stay free, whereever they like. Just add that location to your classpath and everything would work fine.

Hope this helps.
Regards,
Rajarajan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top