I m trying to test sending email in java using java6. The code is this:
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class Sending_email {
final String senderEmail = "ttttt@gmail.com";
final String senderPassword = "123456";
final String emailSMTPserver = "smtp.gmail.com";
final String emailServerPort = "587";
String receiverEmail = null;
String emailSubject = null;
String emailBody = null;
public Sending_email(String receiverEmail, String Subject, String message) {
    this.receiverEmail = receiverEmail;
    this.emailSubject = Subject;
    this.emailBody = message;
    Properties props = new Properties();
    props.put("mail.smtp.user", senderEmail);
    props.put("mail.smtp.host", emailSMTPserver);
    props.put("mail.smtp.port", emailServerPort);
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.socketFactory.port", emailServerPort);
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    //SecurityManager security = System.getSecurityManager();
    try {
        Authenticator auth = new SMTPAuthenticator();
        Session session = Session.getInstance(props, auth);
        Message msg = new MimeMessage(session);
        msg.setText(emailBody);
        msg.setSubject(emailSubject);
        msg.setFrom(new InternetAddress(senderEmail));
        msg.addRecipient(Message.RecipientType.TO,
                new InternetAddress(receiverEmail));
        Transport.send(msg);
        System.out.println("send successfully");
    } catch (Exception ex) {
        System.err.println("Error occurred while sending.!");
    }
}
private class SMTPAuthenticator extends javax.mail.Authenticator {
    public PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(senderEmail, senderPassword);
    }
}
public static void main(String[] args) {
    new Sending_email("tttt@gmail.com", "suerjanct", "erjan lsjflsjdfsldjf");
}
}
However, Eclipse can't compile it. It says
"java.lang.UnsupportedClassVersionError: javax/mail/Authenticator : Unsupported major.minor version 51.0"
51.0 means I run jdk 1.7. but I only have 1.8 and 1.6 installed on my computer!

 
    