when sending the mail from java I am getting the below error

when sending the mail from java I am getting the below error


when sending the mail from java I am getting the below error
:

Exception in thread "main" java.lang.NoClassDefFoundError: javax.mail.internet.MimeMessage
at java.lang.Class.initializeClass(libgcj.so.7rh)
at SendMail.main(SendMail.java:23)
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/mail/mail.jar,file:/mail/], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.7rh)


Code:



SendMail.java


import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

public class SendMail {

public static void main(String args[]) throws Exception {
System.out.println("Message Send.1....");
String host = "xxxxxxxxxxxx";
String from = "[email protected]";
String to = "[email protected]";
System.out.println("Message Send.2....");
// Get system properties
Properties properties = System.getProperties();
System.out.println("Message Send..3...");
// Setup mail server
properties.setProperty("mail.smtp.host", host);

// Get the default Session object.
Session session = Session.getDefaultInstance(properties);
System.out.println("Message Send..4...");
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);

// Set the RFC 822 "From" header field using the
// value of the InternetAddress.getLocalAddress method.
message.setFrom(new InternetAddress(from));

// Add the given addresses to the specified recipient type.
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));


// Set the "Subject" header field.
message.setSubject("hi..!");

// Sets the given String as this part's content,
// with a MIME type of "text/plain".
message.setText("Hi ......");

// Send message
Transport.send(message);

System.out.println("Message Sent.....");
}
}






at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.ClassLoader.loadClass(libgcj.so.7rh)
at java.lang.Class.initializeClass(libgcj.so.7rh)
View Answers

July 2, 2010 at 2:53 PM

Hi Friend,

It seems that you haven't set the classpath to include the mail.jar file. Check it.

For more information, visit the following link:

http://www.roseindia.net/javamail/

Thanks









Related Tutorials/Questions & Answers:
when sending the mail from java I am getting the below error - JavaMail
when sending the mail from java I am getting the below error   when sending the mail from java I am getting the below error : Exception... not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/mail/mail.jar,file
i am getting the problem when i am downloading the pdf file from oracle 10g database - Struts
i am getting the problem when i am downloading the pdf file from oracle 10g... but it is not downloading .Please help to me.i am getting the below error when downloading... into datbase and download the pdf file from database. but when i created the pdf file
Advertisements
i am getting an error in adding a menu item to a menu.
i am getting an error in adding a menu item to a menu.   i am not able to execute the menu program. i am getting an error at menu.add(menuitem); it says add method is undefined for type menu. but as far as i know that is only way
Why the null values are stored in Database when I am sending proper values?
Why the null values are stored in Database when I am sending proper values?  I am making a project in which I am sending the image into a folder &... I am also sending the name, Rate, Dimension to the Database through the text
getting an error when set classpath
getting an error when set classpath  Hello Everyone! i have used hssf model for reading excel sheet in my project & i have set classpath for that jar file but when i compile the program it will compile correctly but when i
:( I am not getting Problem (RMI)
I am not getting Problem (RMI)  When i am excuting RMI EXAMPLE 3,2 I am getting error daying nested exception and Connect Exception  
I am getting this exception
I am getting this exception   Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java
i have split a string by space ,done some operation and now how to properly order them for sending a mail in java or jsp - JSP-Servlet
order them for sending a mail in java or jsp  Dear sir, I have... the matter while sending it and also i am getting a small font size ,i want medium... arraylist and used that string as a argument ,passed in a sending a mail method .Now my
Page is not getting loaded when I refresh the webpage???
Page is not getting loaded when I refresh the webpage???  **I am... function in JSP. It will get all details of image section from database. *I am... when I refresh the page.* Note: Header section is getting loaded always Could
java mail sending with images
java mail sending with images  I need to send images through java mail without giving content path(i.e. we don't want hard code the image path)can you tell me the idea?   Please visit the following links: http
Getting and sending data to and from mobile and the system
Getting and sending data to and from mobile and the system  Hi, For getting and sending data to mobile from system.make system is a server.From mobile send a request to the server and get response.Then process the response
Sending images through java mail
Sending images through java mail  Am trying to develop greeting application that having images..... in one jsp page i displayed all images and by clicking one image the control go to mail sending page in that the image should add
I am getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'IS_AUTHENTICATED_ANONYMOUSLY' is defined - Spring
I am getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'IS_AUTHENTICATED_ANONYMOUSLY' is defined  Hello, I am getting error
i am getting multiple values in listbox
i am getting multiple values in listbox   hi sir, i am using... table group by stuname) order by a.name in a subquery multiple recdates i am getting its working fine, but in main query also i am getting multiple name
i am Getting Some errors in Struts - Struts
i am Getting Some errors in Struts   I am Learning Struts Basics,I am Trying examples do in this Site Examples.i am getting lot of errors.Please Help me
sending a mail - JSP-Servlet
sending a mail   I m writing a code for send mail in jsp,i sending a mail to specified receiver but if i attach an file and send a mail then i m getting an error. Here Attachment is in String[] Attachment=null so how
values of the "from address & to addresses" while sending a mail to localhost using javamail
values of the "from address & to addresses" while sending a mail to localhost using javamail  Hi, I verified javamail tutorial which is mentioned... is,What i have to mention in from address field and To address filed while sending
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized  import java.awt.*; import java.awt.event.*; import java.applet.*; public class Textfields extends Applet implements
Jsp error when i run this a jsp file
Jsp error when i run this a jsp file  hi I got this error when i run the jsp file in IDE and outside also please help me java.lang.NullPointerException org.apache.jsp.insertjsp.jspInit(insert_jsp.java:22
Sending SMS From Java Programs
Sending SMS From Java Programs  I want to develop and application to send sms from my computer, can someone please help me, like tell me where to start and what i need
why it is very slow when I am using the backend as microsoft access file for running the java webapplication - SQL
why it is very slow when I am using the backend as microsoft access file for running the java webapplication  I am using the backend as microsoft access file for running the java webapplication.it is very slow when twoor mor
I am getting error.How can i get details
I am getting error.How can i get details  Exception in thread "main" java.sql.SQLException: Listener refused the connecti n with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect
Sending error code to access log of tomcat server from Action class
Sending error code to access log of tomcat server from Action class  How to send an error code (500) to access log file when we get null value in an if condition in Action class? Is anyone aware of this! Thanks
How do I throw a 404 error from within a java servlet?
How do I throw a 404 error from within a java servlet?  How you can write code in Servlet for throwing the httpd error 404? How to add the configuration for handling the not found error in the web.xml file? Thanks   
iphone mail sending problem
iphone mail sending problem  Hi, I'm receiving the following error ... while sending mail in my iphone application Terminating app due to uncaught... getting this error and to solve it? Thanks in Advance!   Hi all, I get
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
i am unable to identify the error in my code
i am unable to identify the error in my code  class Program { public static void main(String[] args) { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter
I am getting Undefined in Text Box Very Urgent - JSP-Servlet
I am getting Undefined in Text Box Very Urgent  Respected Sir/Madam, I am R.Ragavendran.. Thanks for your superb reply. I got the coding. But I find... and clicking select button, The pop up window gets closes. But, i am getting
How to load elements from db when i press next.
How to load elements from db when i press next.  Hello , I am working on a project "Online Book Mart" using JSP and Servlets and I am astuck... means when i click next, the next 20 books will be displayed from db on the same
No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow  Hi, In one... the errror: No module named 'absl' error when I import tensorflow Earlier... to resolve the error: No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow  Hi, In one... the errror: No module named 'absl' error when I import tensorflow Earlier... to resolve the error: No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow  Hi, In one... the errror: No module named 'absl' error when I import tensorflow Earlier... to resolve the error: No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow  Hi, In one... the errror: No module named 'absl' error when I import tensorflow Earlier... to resolve the error: No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow  Hi, In one... the errror: No module named 'absl' error when I import tensorflow Earlier... to resolve the error: No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow
No module named 'absl' error when I import tensorflow  Hi, In one... the errror: No module named 'absl' error when I import tensorflowADS_TO_REPLACE_1... Python. How to resolve the error: No module named 'absl' error when I
Sending mail - JavaMail
Sending mail  Need a simple example of sending mail in Java ... java.lang.String subject = ""; public java.lang.Exception error;public Mail...() { return error;}public java.lang.String getFrom() { return from
java mail error - JavaMail
java mail error  how to rceive emails using java mail api  Hi Friend, We can use Java Mail APIs to send and receive mails in Java.... Please visit the following link to know more about use of Java Mail API. http
sending mail - JSP-Servlet
sending mail  Hi, what is the code for sending mail automatically without user intervention? thanks in advance
I am from .net background, I want to learn SOA.
I am from .net background, I want to learn SOA.  Hi I am from .net background, I want to learn SOA. Could it possible for me to learn SOA, I suppose SOA includes Java. I dont have knowledge of java. Please help Thanks  
using spring rmi+maven but i am getting this exception
using spring rmi+maven but i am getting this exception  D:\Nexustool\integrationengine\trunk>mvn exec:java [INFO] Scanning for projects... [INFO...-plugin:1.1:java (default-cli) @ engine >>> [INFO] [INFO] <<<
compiled but showing below error
compiled but showing below error  Good morning, By using axis api, am getting the following error but the wsdl file is generating. what is the mistake I done. Unable to find required classes (javax.activation.DataHandler
page is not getting loaded when refreshing???
page is not getting loaded when refreshing???  I am loading an image.... It will get all details of image section from database. I am getting header section always but page is not getting loaded after the header section when I
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java struts 1.3  hii, i am coding a form where i need a keyskills attribute... is displaying.. i need code in java so that it takes multiple values
Getting an error :(
Getting an error :(  I implemented the same code as above.. But getting this error in console... Console Oct 5, 2012 10:18:14 AM...:SpringMVC' did not find a matching property. Oct 5, 2012 10:18:14 AM
sending data from java to facebook wall
sending data from java to facebook wall  how to send data form a java program to facebook wall
Sending mail (Contact Form in a website)
Sending mail (Contact Form in a website)  Hi, I just uploaded few of my webpages into a free web hosting service, where i can just upload the web pages. Am very much new into this field. I want to write a contact form, which
sending mail using jsp
sending mail using jsp  please give me the detailed procedure and code for sending mail through jsp program   Please visit the following links: http://www.roseindia.net/ejb/introduction/j2eedemo.shtml http
when I run exiting project that time I got error, I want solution on it?
when I run exiting project that time I got error, I want solution on it?  Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start
how i get experience wise resume from database when i submit from browser
how i get experience wise resume from database when i submit from browser  how i get experience wise resume from database when i submit from browser   Please go through the following link: Visit Here
error for getting the data from an api using br.readLine - Development process
error for getting the data from an api using br.readLine  hi... the data is coming from remote using particular api call see the following code... executing the above while loop the application is hanging . i find

Ads