Home Answers Viewqa JavaMail when sending the mail from java I am getting the below error

 
 


pradeep
when sending the mail from java I am getting the below error
1 Answer(s)      2 years and 11 months ago
Posted in : JavaMail


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 = "xxx@gmail.com";
String to = "xxx@yahoo.com";
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 Pages:
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
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
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
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
:( 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  
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
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
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
sending email using smtp in java
sending email using smtp in java  Hi all, I am trying to send..., password); } return null; } } } When i run this program i am getting following exception: DEBUG: setDebug: JavaMail version 1.4.4 DEBUG
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
Sending large data to Action Class error. Struts code - Struts
Sending large data to Action Class error. Struts code  I have a jsp page and there is a button which is a image type ,when i click on the button I am... is - Visual Studio 2005 in the case of .NET technology - Eclipse in the case of Java
JAVA MAIl - JavaMail
JAVA MAIl  Hi, I am trying to send a mail using java mail api. But I am getting following error: javax.mail.SendFailedException: Sending failed... this error?   Hi Friend, Please visit the following link
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
problem in getting mail exchange records(MX) using DNS in java
problem in getting mail exchange records(MX) using DNS in java  Hi...) at java.lang.Thread.run(Thread.java:619) Note : I am using glassfish v3. above code works fine......."+attributeMX); } catch(Exception e){ out.println("Error ****"+e
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
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
Java Mail - JMS
running very well,creating no other problems. Now i am trying to learn java mail service. I hav written a sample mail program to just test the code.The code is given below................. //My first java mail program............. import
java mail
(System.out); } } } Hi..I got this code from a site and im getting...(MailClient.java:90) help me clear this error..send suggestions to mail mail...: Java Mail Thanks
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
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] <<<
Java Mail - JSP-Servlet
Java Mail  hi, i refer ur J2EE Tutorial - Send Email From JSP & Servlet to send emails from my application.but when i run the jsp it will throw thhese exceptions. ERROR.....javax.mail.SendFailedException: Sending failed
mail
mail  I wrote a program to send mail using smtp. But there is an error message " could not connect to smtp.gmail.com port 465. what is the problem how can i solve it ...   Please visit the following link: Java Mail API
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
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
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
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
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown... an internal error () that prevented it from fulfilling this request. exception
how to make this java mail works? - Java Beginners
work, for I am really keen to include a java mail inside my application. Now, I...how to make this java mail works?  Dear experts, Recently, I... version from: http://www.oracle.com/technetwork/java/index-138643.html But, I
Cheking birthday excel sheet everyday and Sending Automated MAIL to birthday boy on his birthday
Cheking birthday excel sheet everyday and Sending Automated MAIL to birthday boy on his birthday  hi all I am toatally new to java programming can anyone help me out in the procedure for sending automated mail to the birthday
regarding sending mesage - JavaMail
me in this regard   Hi friend, I am sending you a link...regarding sending mesage  i have tried the following program... = "192.168.10.205"; String from = "test@localhost"; String
Java Mail exception - JavaMail
Java Mail exception  Hi! I am developing E-mail Client (GMAIL) program using JSP technology. Till now i dont have any problem. From last 3 days while i am connecting to the Gmail, I am getting the following exception... Whats
JAVA Mail - JavaMail
JAVA Mail  Hi! I am trying to send the mail using SMTP of gmail. program was compiled successfully. when i am trying to execute that program it is showing error --- Must issue STARTTLS command first... How to avoid
Sending email with read and delivery requests
Sending email with read and delivery requests  Hi there, I am sending emails using JavaMail in Servlets on behalf of a customer from the website...   To read a mail, visit the following link: Java Read Mail
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 an email in JSP
Sending an email in JSP       Sending an email in JSP In this section, you will learn how to send an email in jsp.   Following is a simple JSP page for sending
sending commands through RxTx
sending commands through RxTx  i am trying to call lightOn and LightOff method from NewSerialWriter's run() method but not able to make the correct..."); if(commPortIdentifier.isCurrentlyOwned()) { System.out.println("Error: Port is currently in use
Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.
Getting error java.lang.ClassNotFoundException: com.mysql.jdbc.Driver.  I am doing project in JSP with database WampServer and glassfish as server .when i done database connection then i get an error
Sending Emails In Java
Sending Emails In Java  I want to send emails from within a java program. I saw some online java programs to do that, but they needed me to enter... with how to write the code?   Please visit the following link: Java Mail
Sending Emails In Java
Sending Emails In Java  I want to send emails from within a java program. I saw some online java programs to do that, but they needed me to enter... with how to write the code?   Please visit the following link: Java Mail
Sending Emails In Java
Sending Emails In Java  I want to send emails from within a java program. I saw some online java programs to do that, but they needed me to enter... with how to write the code?   Please visit the following link: Java Mail
send the mail with attachment - Struts
send the mail with attachment   Hi Freinds, i am sending the mail without attachment file now. But i need to send the mail with attachment in struts. when i added the attachemt logic in struts,i am not able to send
java mail
java mail  this code showing an error couldn't connect smtp host please help <%@ page language="java" import="javax.naming.*,java.io....(); out.println("Thanks for sending mail!"); } catch(Exception e
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
Getting NumberFormatException
. I used the same type of code in a simple .java program but when I.m using it in a JSP it continuously throws the exception. below is the code I used. Please...Getting NumberFormatException  Hello Sir, I'm using Integer.parseInt
problem getting password - JavaMail
problem getting password  hi i am trying to get password but igot following error Error sending mail:javax.mail.MessagingException: Could not connect to SMTP host: 192.168.10.14, port: 25;nested exception
Reply to ur mail(Hibernate Error)
Reply to ur mail(Hibernate Error)  Hi! Im using Eclipse. Steps : 1. Downloaded the example code and library from rose india and extracted the content... the Eclipse project and selected Java Project. 4. Created a new project browsing
Java Mail API - JavaMail
account using java mail api... i got code from our roseindia.net i.e....Java Mail API  Hi! I wish u advanced happy new year to all of ur...("pop3s"); after successful compilation, at runtime i am getting the following exce
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
sending mail with attachment in jsp - JSP-Servlet
sending mail with attachment in jsp  Hi, Can any one pls tell me how to send email with attachment in jsp. I know how to send mail without.... Thanks  Hi Frnd, Sry to tell u this,, actly i tried dat... bt its nt

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.