我这有个例子
package mytest;import java.awt.*;
import java.awt.event.*;
import java.applet.*;public class Applet1 extends Applet {
  private boolean isStandalone = false;
  BorderLayout borderLayout1 = new BorderLayout();
  Button button1 = new Button();
  //Get a parameter value
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
      (getParameter(key) != null ? getParameter(key) : def);
  }  //Construct the applet
  public Applet1() {
  }
  //Initialize the applet
  public void init() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception {
    button1.setLabel("button1");
    button1.addActionListener(new Applet1_button1_actionAdapter(this));
    this.setLayout(borderLayout1);
    this.add(button1, BorderLayout.SOUTH);
  }
  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }
  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }
  //Main method
  public static void main(String[] args) {
    Applet1 applet = new Applet1();
    applet.isStandalone = true;
    Frame frame;
    frame = new Frame();
    frame.setTitle("Applet Frame");
    frame.add(applet, BorderLayout.CENTER);
    applet.init();
    applet.start();
    frame.setSize(400,320);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
    frame.setVisible(true);
  }  void button1_actionPerformed(ActionEvent e) {
    try{
      Runtime.getRuntime().exec(
          "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE");
    }catch(Exception ex)
    {    }
  }
}class Applet1_button1_actionAdapter implements java.awt.event.ActionListener {
  Applet1 adaptee;  Applet1_button1_actionAdapter(Applet1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.button1_actionPerformed(e);
  }
}

解决方案 »

  1.   

    我也做过一个和你类似的程序。两种语言间使用Socket通信,连接打开流后不要使用你所写的流in = new BufferedReader(new InputStreamReader( ClientSocket.getInputStream() ));
    out = new PrintWriter(ClientSocket.getOutputStream(), true);你只需要打开一个字节流 InputStream and OutputStream 
    如果使用缓冲流它是不会读完一行的,会一直堵塞的,你需要用 read() and write()一个一个字节的去读和写,通信时一定要定义消息头和尾,根据消息头和尾来截取一个完整的消息。祝你好运