Name: skT88420 Date: 01/31/2000
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)
I am running a very simple sendmail program with Java Help. The program runs
fine, but when I exit I get this message.
#
# HotSpot Virtual Machine Error, EXCEPTION_ACCESS_VIOLATION
#
# Error ID: 4F533F57494E13120E43505002BE
#
abnormal program termination
THIS IS THE SOURCECODE
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.help.*;//importaci?n de la ayuda
class sendmail extends Frame implements WindowListener, ActionListener{
//Creaci?n de objetos para ayuda HelpBroker y HelpSet
HelpBroker HB;
HelpSet HS;
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
Label serverl = new Label("Server:", Label.CENTER);
TextField server = new TextField();
Label froml = new Label("From:", Label.CENTER);
TextField from = new TextField();
Label tol = new Label("To:", Label.CENTER);
TextField to = new TextField();
Label subjectl = new Label("Subject:", Label.CENTER);
TextField subject = new TextField();
TextArea data = new TextArea();
TextArea status = new TextArea(4, 1);
Button send = new Button("Send");
//Creaci?n de menus
MenuBar menuBar= new MenuBar();
Menu menuAyuda = new Menu("Ayuda");
MenuItem contenido= new MenuItem("Contenido");
MenuItem indice = new MenuItem("Indice");
MenuItem buscar = new MenuItem("Buscar");
MenuItem acerca = new MenuItem("Acerca de...");
//Creaci?n de bot?n de ayuda.
Button bayuda = new Button("?");
public sendmail(){
setTitle("SendMail");
setSize(400,500);
ayuda();
setLayout(layout);
setBackground(Color.lightGray);
addWindowListener(this);
//Inserci?n de men?s
menuAyuda.add(contenido);
menuAyuda.add(indice);
menuAyuda.add(buscar);
menuAyuda.add(acerca);
menuBar.add(menuAyuda);
setMenuBar(menuBar);
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
add(serverl);
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(server, c);
add(server);
add(froml);
layout.setConstraints(from, c);
add(from);
add(tol);
layout.setConstraints(to, c);
add(to);
add(subjectl);
layout.setConstraints(subject, c);
add(subject);
c.weighty = 1;
layout.setConstraints(data, c);
add(data);
status.setEditable(false);
c.weighty = 0;
layout.setConstraints(status, c);
add(status);
send.addActionListener(this);
layout.setConstraints(send, c);
add(send);
layout.setConstraints(bayuda,c);
add(bayuda);
setVisible(true);
}
public void ayuda(){
//nos indica donde se encuentra el archivo helpset.hs y crea el objeto
helpbroker con esos datos
try {
URL ayudaURL = HelpSet.findHelpSet(null,
"./Ayuda/helpset.hs");
HS = new HelpSet(null, ayudaURL);
} catch (Exception ee) {
System.out.println("La ayuda no se encontr?");
return;
}
HB = HS.createHelpBroker();
impleayuda();
}
public void impleayuda(){ //Implementa la ayuda en botones, men?s, etc.
HB.enableHelpKey(server , "1",
null);//HelpBroker.activaTecladF1(objeto, "referencia", HelpSet)
HB.enableHelpKey( from, "2", null);
HB.enableHelpKey( to, "3", null);
HB.enableHelpKey( subject, "4", null);
HB.enableHelpKey( data, "5", null);
HB.enableHelpKey( status, "6", null);
HB.enableHelpKey( send, "7", null);
HB.enableHelpOnButton(acerca, "8", null);
bayuda.addActionListener(new CSH.DisplayHelpAfterTracking(HB));
//boton.activarEscuchadorDeEventos(nuevo
CSH.ActivaLaAyudaDespuesDelClick(HelpBroker),
}
public static void main (String[] args) {
Frame myframe = new sendmail();
}
public void windowClosing(WindowEvent event) {
System.exit(0);
}
public void windowClosed(WindowEvent event) {}
public void windowOpened(WindowEvent event) {}
public void windowIconified(WindowEvent event) {}
public void windowDeiconified(WindowEvent event) {}
public void windowActivated(WindowEvent event) {}
public void windowDeactivated(WindowEvent event) {}
public void actionPerformed(ActionEvent e){
try{
String s;
Socket socket = new Socket(server.getText(),25);
PrintWriter printer = new
PrintWriter(socket.getOutputStream(),true);
BufferedReader reader = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
status.setText("");
s = reader.readLine();
if(!s.startsWith("220")){
status.append("Error: " + s.substring(4) +
"\n");
printer.println("quit");
status.append("Closing connection.\n");
return;
}else{
status.append("Connection made to host.\n");
}
printer.println("helo " + server.getText());
s = reader.readLine();
if(!s.startsWith("250")){
status.append("Error: " + s.substring(4) +
"\n");
printer.println("quit");
status.append("Closing connection.\n");
return;
}else{
status.append("Computers introduced
properly.\n");
}
printer.println("mail from: " + from.getText());
s = reader.readLine();
if(!s.startsWith("250")){
status.append("Error: " + s.substring(4) +
"\n");
printer.println("quit");
status.append("Closing connection.\n");
return;
}else{
status.append("Sender OK.\n");
}
printer.println("rcpt to: " + to.getText());
s = reader.readLine();
if(!s.startsWith("250")){
status.append("Error: " + s.substring(4) +
"\n");
printer.println("quit");
status.append("Closing connection.\n");
return;
}else{
status.append("Recipient OK.\n");
}
printer.println("data");
s = reader.readLine();
if(!s.startsWith("354")){
status.append("Error: " + s.substring(4) +
"\n");
printer.println("quit");
status.append("Closing connection.\n");
return;
}else{
status.append("Ready for data transfer.\n");
}
printer.println("subject: " + subject.getText());
printer.println(data.getText());
printer.println(".");
status.append("Data transfer complete.\n");
s = reader.readLine();
if(!s.startsWith("250")){
status.append("Error: " + s.substring(4) +
"\n");
printer.println("quit");
status.append("Closing connection.\n");
return;
}else{
status.append("Message accepted for
delivery.\n");
}
printer.println("quit");
s = reader.readLine();
if(!s.startsWith("221")){
status.append("Error: " + s.substring(4) +
"\n");
printer.println("quit");
status.append("Closing connection.\n");
return;
}else{
status.append("Connection closed.\n");
}
reader.close();
printer.close();
socket.close();
}catch(Exception ex){status.append("Error: " + ex + "\n");}
}
}
(Review ID: 100538)
======================================================================