2013-05-31 5 views
0

는 내가 .. 화상 회의 서버를 시작하려고하지만, 실행하는 동안 오류가 .. 그래서 사람이 클라이언트가 저와 연결 얻을 수 있도록 내가 내 서버를 시작하는 방법 내 실수입니다 나를 도울 수 있어요Java에서 미해결 컴플라이언스 오류를 해결하는 방법은 무엇입니까?

 package chat; 

    import java.awt.Button; 
    import java.awt.Choice; 
    import java.awt.Color; 
    import java.awt.Component; 
    import java.awt.Container; 
    import java.awt.Event; 
    import java.awt.Frame; 
    import java.awt.Image; 
    import java.awt.Insets; 
    import java.awt.Label; 
    import java.awt.List; 
    import java.awt.MediaTracker; 
    import java.awt.Menu; 
    import java.awt.MenuBar; 
    import java.awt.MenuItem; 
    import java.awt.TextArea; 
    import java.awt.TextComponent; 
    import java.awt.Toolkit; 
    import java.awt.Window; 
    import java.io.IOException; 
    import java.io.PrintStream; 
    import java.net.ServerSocket; 

    public class ChatServer extends Frame 
    { 
     static final int DEFAULT_USERCOUNT = 3; 
     static final int DEFAULT_PORT = 10000; 
     static final String ICON_FILE = "icon.gif"; 
    int num_Line = 0; 
    User[] users = null; 
    User_webBrowser[] users_webBrowser = null; 
    User_Video[] users_Video = null; 
    User_Audio[] users_Audio = null; 
    ServerSocket ss = null; 
    ServerSocket ss1 = null; 
    ServerSocket ss2 = null; 
    ServerSocket ss3 = null; 
    RoomGroup roomGroup = null; 
    int port = 10000; 
    Image icon = null; 
    String IP = null; 
     TextArea message_TextArea; 
     List users_List; 
     Choice room_Choice; 
     Label message_Label; 
     Label room_Label; 
     Label userList_Label; 
     Button clean_Button; 
     MenuBar mainMenuBar; 
     Menu menu1; 
     Menu menu3; 

     void initServer(int port) 
     throws IOException 
     { 
     this.users = new User[3]; 
     this.users_webBrowser = new User_webBrowser[3]; 
     this.users_Video = new User_Video[3]; 

     this.roomGroup = new RoomGroup(3, this.room_Choice, this); 
     try { 
     this.ss = new ServerSocket(port, 5); 
     this.ss1 = new ServerSocket(port + 1, 5); 
     this.ss2 = new ServerSocket(port + 2, 5); 
     this.ss3 = new ServerSocket(port + 3, 5); 
     this.message_TextArea.appendText(
      "\nserver socket init successed"); 
     } 
     catch (Exception e) { 
     System.out.println(e); 
     this.message_TextArea.appendText(
      "\nserver socket init error" + e); 
     } 
     for (int i = 0; i < this.users.length; i++) 
     { 
     this.users[i] = new User(this, i); 
     this.users_webBrowser[i] = new User_webBrowser(this, i); 
     this.users_Video[i] = new User_Video(this, i); 
     } 

     this.roomGroup.setUsers(this.users); 
     show(); 
     go(); 
     this.message_TextArea.appendText("\nserver started"); 
     } 

     ChatServer(int port) 
     throws IOException 
     { 
     this.icon = getToolkit().getImage("icon.gif"); 
     MediaTracker tracker = new MediaTracker(this); 
     tracker.addImage(this.icon, 0); 
     try { 
     tracker.waitForAll(); 
     } catch (Exception e) { 
     System.out.println(e); 
     } 

     setLayout(null); 
     addNotify(); 
     resize(insets().left + insets().right + 544, insets().top + insets().bottom + 355); 

     setTitle("Video conference system server V1.0"); 
     setIconImage(this.icon); 

     setBackground(new Color(14542583)); 

     this.message_TextArea = new TextArea(); 
     this.message_TextArea.reshape(insets().left + 12, 
     insets().top + 36, 396, 240); 
     add(this.message_TextArea); 
     this.users_List = new List(5, false); 
     add(this.users_List); 
     this.users_List.reshape(insets().left + 432, insets().top + 
     144, 76, 110); 
     this.room_Choice = new Choice(); 
     add(this.room_Choice); 
     this.room_Choice.reshape(insets().left + 420, insets().top + 
     60, 100, 1); 
     this.message_Label = new Label("Server Message"); 
     this.message_Label.reshape(insets().left + 36, insets().top + 
     12, 100, 24); 
     add(this.message_Label); 
     this.room_Label = new Label("Meeting Room"); 
     this.room_Label.reshape(insets().left + 420, insets().top + 
     14, 100, 24); 
     add(this.room_Label); 
     this.userList_Label = new Label("User Lists"); 
     this.userList_Label.reshape(insets().left + 420, insets().top + 
     108, 100, 28); 
     add(this.userList_Label); 
     this.clean_Button = new Button("Remove"); 
     this.clean_Button.reshape(insets().left + 180, insets().top + 
     12, 60, 24); 
     add(this.clean_Button); 

     this.mainMenuBar = new MenuBar(); 

     this.menu1 = new Menu("File"); 
     this.menu1.add("Restart"); 
     this.menu1.add("Quit"); 
     this.mainMenuBar.add(this.menu1); 

     this.menu3 = new Menu("Help"); 
     this.mainMenuBar.setHelpMenu(this.menu3); 
     this.menu3.add("About"); 
     this.mainMenuBar.add(this.menu3); 
     setMenuBar(this.mainMenuBar); 

     this.port = port; 
     initServer(port); 
     } 

     ChatServer() 
     throws IOException 
     { 
     this(10000); 
     } 

     void cleanButton_Clicked(Event event) 
     { 
     this.message_TextArea.setText(""); 
     } 

     void About_Action(Event event) 
     { 
     new AboutDialog(this, true).show(); 
     } 

     void Exit_Action(Event event) 
     { 
     new QuitDialog(this, true).show(); 
     } 

     void Restart_Action(Event e) 
     { 
     try { 
     quit(); 
     initServer(this.port); 
     } catch (Exception e1) { 
     this.message_TextArea.appendText("\ninit server error"); 
     } 
     } 

     public synchronized void show() 
     { 
     move(50, 50); 

     super.show(); 
     } 

     void roomChoice_Action(Event e) 
     { 
     String roomName = null; 
     int roomID = 0; 

     this.users_List.clear(); 
     roomName = this.room_Choice.getSelectedItem(); 
     roomID = this.roomGroup.getRoomID(roomName); 
     for (int i = 0; i < this.users.length; i++) 
     if ((this.users[i].logged) && (this.users[i].belongRoom) && 
      (this.users[i].roomID == roomID)) 
      this.users_List.addItem(this.users[i].name); 
     } 

     int roomNum() 
     { 
     String roomName = null; 
     int roomID = 0; 

     this.users_List.clear(); 
     roomName = this.room_Choice.getSelectedItem(); 
     roomID = 0; 
     int k = 0; 
     for (int i = 0; i < this.users.length; i++) { 
     if ((this.users[i].logged) && (this.users[i].belongRoom) && 
      (this.users[i].roomID == roomID)) { 
     this.users_List.addItem(this.users[i].name); 
      k++; 
      } 
     } 
     return k; 
     } 

     public boolean handleEvent(Event event) 
     { 
     if (event.id == 201) { 
     quit(); 
     hide(); 
     dispose(); 
     System.exit(0); 
     return true; 
     } 
     if ((event.target == this.room_Choice) && (event.id == 
     1001)) { 
     roomChoice_Action(event); 
     return true; 
     } 
     if ((event.target == this.clean_Button) && (event.id == 
     1001)) { 
     cleanButton_Clicked(event); 
     return true; 
     } 

     return super.handleEvent(event); 
     } 

     public boolean action(Event event, Object arg) 
     { 
     if ((event.target instanceof MenuItem)) { 
     String label = (String)arg; 
     if (label.equalsIgnoreCase("About")) { 
      About_Action(event); 
     return true; 
      } 
     if (label.equalsIgnoreCase("Quit")) { 
     Exit_Action(event); 
     return true; 
      } 
     if (label.equalsIgnoreCase("Restart")) { 
     Restart_Action(event); 
     return true; 
      } 
     } 
    return super.action(event, arg); 
     } 

     public static void main(String[] args) 
     { 
     try 
     { 
     chatServer = new ChatServer(); 
     } 
     catch (Exception e) 
     { 
      ChatServer chatServer; 
     System.out.println(e); 
     } 
     } 

     public void go() 
     { 
     for (int i = 0; i < this.users.length; i++) { 
     this.users[i].start(); 
     this.users_webBrowser[i].start(); 
     this.users_Video[i].start(); 
     } 
     } 

     public void quit() 
     { 
    for (int i = 0; i < this.users.length; i++) { 
     if (this.users[i] != null) this.users[i].destroy(); 
     if (this.users_webBrowser[i] != null) this.users_webBrowser[i].destroy(); 
     if (this.users_Video[i] != null) this.users_Video[i].destroy(); 
     } 
     try 
     { 
     this.ss.close(); 
     this.ss = null; 
     this.ss1.close(); 
     this.ss1 = null; 
     this.ss2.close(); 
     this.ss2 = null; 
     this.ss3.close(); 
     this.ss3 = null; 
     this.room_Choice.removeAll(); 
     this.users_List.clear(); 
     this.message_TextArea.appendText(
      "\nserver socket closed"); 
     } 
     catch (IOException e) { 
     System.out.println(e); 
     } 
     } 
    } 

스택

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    chatServer cannot be resolved to a variable 
    at chat.ChatServer.main(ChatServer.java:275) 
+3

김 오류가 무엇입니까? 스택 추적 및 오른쪽 라인 포인터? – ddmps

+3

1. 문제를 나타내는 가능한 실행 가능한 최소의 프로그램으로 코드를 줄이십시오. 2. 전체 예외를 게시하십시오. – Keppil

+0

stacktrace를 업데이트합니다. –

답변

1

추적 기분을 상하게하는 라인은 : 공중 정적 무효 메인 (문자열 [] 인수)에

chatServer = new ChatServer(); 

01,

그러나 이전에 chatServer 변수를 선언하지 않았습니다.

시도 :

try { 
    ChatServer chatServer = new ChatServer(); 
} catch (Exception e) { 
    System.out.println(e); 
} 
+0

이 @NickJ를 시도했지만 여전히 같은 오류가 발생합니다. –

+0

컴파일 오류가있는 Java 프로그램을 실행하려고하면 오류가 발생합니다. 실제 컴파일 오류는 무엇을 말합니까? – NickJ

+0

그게 stacktrace 동부 .. 줄 번호와 코드 아래에 내 stacktrace을 참조하십시오. –

관련 문제