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
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");

// 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..

That doesn't solve the problem, it masks it but it will come back to bite you later.

The problem here is almost certainly classpath related.
Most likely the jar depends on other jars that aren't on the classpath (like mail.jar, activation.jar, and things like that).

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.