java.lang.NoSuchMethodError: main. Exception in thread "main"
<p>Hello I'm trying to mail from Java.</p>

<p>I'm getting this runtime exception:</p>

<blockquote>
  <p>java.lang.NoSuchMethodError: main. Exception in thread "main"</p>
</blockquote>

<p>Cant figure out what the problem is. Please help.</p>

<p>I'm using the following code:</p>

<pre><code>import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.Message.RecipientType;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class Mail{
 public static void Mail(String from, String to, String subject, String text)
 {

  Properties props = new Properties();
  props.put("mail.smtp.host", "smtp.gmail.com");
  props.put("mail.smtp.port", "465");

  Session mailSession = Session.getDefaultInstance(props, null);
  Message simpleMessage = new MimeMessage(mailSession);

  InternetAddress fromAddress = null;
  InternetAddress toAddress = null;
  try
  {
   fromAddress = new InternetAddress(from);
   toAddress = new InternetAddress(to);
  } catch (AddressException e)
  {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

  try
  {
   simpleMessage.setFrom(fromAddress);
   simpleMessage.setRecipient(RecipientType.TO, toAddress);
   simpleMessage.setSubject(subject);
   simpleMessage.setText(text);

   Transport.send(simpleMessage);   
  } catch (MessagingException e)
  {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }  
 }

 public static void main(String[] args) 
 {

  String from = "prav.br@gmail.com";
  String to = "prav.br@gmail.com";
  String subject = "Test";
  String message = "A test message";

  Mail.Mail(from, to, subject, message);

 }
}
</code></pre>
