十万火急!!谢谢!!
在 public void actionPerformed(ActionEvent ae)开始提示:非法的表达式开始
把这个PUBLIC屏蔽后在下面的每个public行都出现:非法的表达式开始
各路高手救命啊
源码:import java.awt.*;
import java.awt.event.*;
import java.rmi.*;
import java.rmi.server.*;public class client extends Frame implements ActionListener,KeyListener,Notfiable{
    int flag = 0;
    String s;
    String userName;
    String welcome;
    String input;
    TextArea TextArea;
    TextField inputText;
    Label hello;
    
    RemoteInterface server;
    public client(){
            addWindowListener(new WindowAdapter(){
               public void windowClosing(WindowEvent e){
                      System.exit(0);
                   }
               });
               Panel up = new Panel();
               Panel down = new Panel();
               this.add(up,BorderLayout.NORTH);
               this.add(down,BorderLayout.SOUTH);
               welcome = "hello,stone!!";
               hello = new Label(welcome);
               TextArea = new TextArea(s,15,50,TextArea.SCROLLBARS_BOTH);
               TextArea.setEditable(false);
               up.add(hello,BorderLayout.NORTH);
               up.add(TextArea,BorderLayout.SOUTH);
               
               inputText = new TextField(35);
               Button send = new Button("send");
               down.setBackground(Color.pink);
               down.add(inputText);
               down.add(send);
               
               send.addActionListener(this);
               inputText.addKeyListener(this);
               try{
                    UnicastRemoteObject.exportObject(this);
                   }catch(RemoteException re){
                        re.printStackTrace();
                       }
          //从这里开始,把这个屏蔽了下个public的地方又出现非法表达式的开始    
         public void actionPerformed(ActionEvent ae){
                   if(ae.getActionCommand().equals("send")){
                        try{
                            server.setChatText(userName+":"+inputText.getText());
                            inputText.setText(null);
                           }catch(RemoteException re){
                                re.printStackTrace();
                               }
                       }
                   }
                   
              public void keyPressed(KeyEvent ev){
                    int keyCode = ev.getKeyCode();
                    if(keyCode==KeyEvent.VK_ENTER){
                        try{
                                server.setChatText(userName+":"+inputText.getText());
                                inputText.setText(null);
                             }catch(RemoteException re){
                                  re.printStackTrace();
                                 }
                       }
                   }    
                   
               public void keyReleased(KeyEvent ev){}
               public void keyTyped(KeyEvent ev){}    
               public void notify(Integer reason){
                    if(reason.intValue()==0){
                        try{
                                input = server.getChatText();
                                s = TextArea.getText()+"\r\n";
                                TextArea.setText(s+input);
                              }catch(RemoteException re){
                                    re.printStackTrace();
                                 }
                       }
                   }
                   
               public static void main(String[] args){
                    if(args.length==0){
                          System.out.println("USAGE: java <username>");
                          System.exit(0);
                        }
                       System.setSecurityManager(new RMISecurityManger());
                       client f = new client();
                       f.username = args[0];
                       try{
                              f.server = (RemoteInterface)Naming.lookup("rmi://127.0.0.1/test");
                              f.server.registerForNotification(f);
                           }catch(Exception e){
                                e.printStackTrace();
                               }
                       f.setSize(400,350);
                       f.show();        
                   }    
         }
   }

解决方案 »

  1.   

    我刚刚也碰到了这个问题 上网找了一下 问题是在构造函数最后面少了个"}"                               try{ 
                                            UnicastRemoteObject.exportObject(this); 
                                          }catch(RemoteException   re){ 
                                                    re.printStackTrace(); 
                                                  }     // 应当在这里加个"}"