944,085 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2849
  • Java RSS
Mar 5th, 2007
0

error while running jar file

Expand Post »
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 = "
from@mail.com"
String to = "
tomail@gitech.in";

// 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..
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Venks is offline Offline
35 posts
since Feb 2007
Mar 5th, 2007
0

Re: error while running jar file

Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004
Mar 5th, 2007
0

Re: error while running jar file

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).
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: In about Jboss.xml
Next Thread in Java Forum Timeline: how to pop up an html file from your Java GUI





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC