Source

import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.awt.event.*;
import java.applet.*;

class Sender {
   Transmitter trn = null;
   byte [] classbytes = null;
   BufferedReader in;
   ObjectOutputStream out;

   public Sender(Transmitter trn) { 
      this.trn = trn; 
      trn.status.setText("Ready to send");
   }

   public void sendit (String classname) {
      try {
	 FileInputStream in = new FileInputStream (classname+".class");
	 ByteArrayOutputStream buffer = new ByteArrayOutputStream();
	 int ch;
	 while ((ch = in.read()) != -1) buffer.write(ch);
	 classbytes = buffer.toByteArray();
      } catch (Exception e) {
	 trn.status.setText("No such class: "+classname+".class");
	 return;
      }

      try {
	 Socket socket = new Socket("localhost", 8670);
         InputStream ins = socket.getInputStream();
         in  = new BufferedReader(new InputStreamReader(ins));
         out = new ObjectOutputStream(socket.getOutputStream());
	 out.writeObject(classname);
	 out.writeObject(classbytes);
	 in.close();
	 out.close();
	 socket.close();
	 trn.status.setText("Class information sent successfully");
      } catch (SocketException e) {
	 trn.status.setText("Cannot connect to server...is it running?");
      } catch (IOException e) {
	 trn.status.setText("Cannot create stream to server");
      }
   }
}

public class Transmitter extends Applet implements ActionListener {
   Sender sender = null;
   JTextField status = null, classname = null;
   JButton doit = null;

   public void init () {
      setLayout(new BorderLayout());
      add("North",status = new JTextField());

      JPanel p = new JPanel();
      p.setLayout(new FlowLayout());
      p.add(classname = new JTextField(20));
      p.add(new JLabel("  "));
      p.add(doit = new JButton("Send it"));
      add("South",p);
      status.setEditable(false);
      doit.addActionListener(this);
   }

   public void start () {
      sender = new Sender(this);
   }

   public void actionPerformed (ActionEvent evt) {
      sender.sendit(classname.getText());
   }
}