Hai friends iam doing project in swing ,in my project i want to send email while running my project..
i added the following code for email:
String host = "mail.gitech.in";
String from = ""
String to = "";
// Get system properties
try
{
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("The Subject");
message.setText(msg);
// Send message
Transport.send(message);
}
cathch(Exception e){}
my problem is while running jar file from command prompt(java -jar jarfilename .jar) means its working fine , but while double clicking jar file means it gives "could not find the main class. program will exit" ,help me please..