import javax.mail.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
import javax.mail.internet.*;
public class Neon extends JFrame {
public JButton ok,limpar,sair;
public JTextArea editor;
public JScrollPane rolagem;
public JTextField texto1,texto2,texto3;
public JLabel label1,label2,label3,label4;
public Neon(String nome1,String nome2,String nome3,String nome4)
{
super("Neonmail");
texto1 = new JTextField(20);
texto2 = new JTextField(20);
texto3 = new JTextField(20);
label1 = new JLabel(nome1);
label2 = new JLabel(nome2);
label3 = new JLabel(nome3);
label4 = new JLabel(nome4);
ok = new JButton("Send");
limpar = new JButton("Clear");
sair = new JButton("Quit");
editor = new JTextArea(10,20);
editor.setLineWrap(true);
rolagem = new JScrollPane(editor);
JPanel painel = new JPanel();
painel.add(label1);
painel.add(texto1);
painel.add(label2);
painel.add(texto2);
painel.add(label3);
painel.add(texto3);
painel.add(label4);
painel.add(rolagem);
painel.add(ok);
painel.add(limpar);
painel.add(sair);
Container container = getContentPane();
container.add(painel);
setVisible(true);
setSize(400,400);
setLocation(300,300);
}
public void setClear()
{
limpar.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
editor.setText("");
texto1.setText("");
texto2.setText("");
texto3.setText("");
}
});
}
public void setQuit()
{
sair.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evento1)
{
System.exit(0);
}
}
);
}
public void setSending() {
ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evento2)
{
Properties properties = new Properties();
properties.put("smtp.netsite.com.br","smtp.netsite.com.br");
Session session = Session.getInstance(properties, null);
MimeMessage msg = new MimeMessage(session);
try
{
msg.setFrom(new InternetAddress(texto1.getText()));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(texto2.getText()));
msg.setSentDate(new Date());
msg.setSubject(texto3.getText());
msg.setText(editor.getText());
Transport.send(msg);
}
catch (AddressException e)
{
System.out.println("Error: " + e);
}
catch (MessagingException mes)
{
System.out.println("Error: " + mes);
}
}
});
}
public static void main(String args[])
{
Neon neon = new Neon("From:","To:","Subject:","Message:");
neon.setClear();
neon.setQuit();
neon.setSending();
}
}
???
[root@localhost neon]# java -classpath /javamail/javamail-1.3.1/mail.jar Neon
Exception in thread “main” java.lang.NoClassDefFoundError: Neon
Vc deve acresentar o .;
java -classpath .;/javamail/javamail-1.3.1/mail.jar Neon