2012-11-02 45 views
0
package uk.ac.hw.oncrpc; 
import org.acplt.oncrpc.*; 
import org.acplt.oncrpc.server.*; 

import uk.ac.hw.quizgame.Game; 

import java.io.IOException; 

public class quizServer extends quizServerStub { 
    private double sum; 

    public quizServer() throws OncRpcException, IOException { 
     //sum = 0.0; May used quiz globals here 
    } 


    @Override 
    public void start_1(String arg1) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public String requestQuestion_1() { 
     // TODO Auto-generated method stub 
     String question = "What is the atomic number of lithium?"; 

     return question; 
    } 

    @Override 
    public String checkAnswer_1(String arg1) { 
     // TODO Auto-generated method stub 
     return null; 
    } 

    @Override 
    public void quit_1(String arg1) { 
     // TODO Auto-generated method stub 

    } 

    @Override 
    public void help_1(String arg1) { 
     // TODO Auto-generated method stub 

    } 

    public static void main(String[] args) { 
     try { 
      quizServer server = new quizServer(); 
      System.out.println("Quiz ready"); 
      server.run(); 
     } catch (Exception e) { e.printStackTrace(System.out); } 
    } 

} 

對於上面的代碼,我從編譯如下服務器端Java應用程序代碼沒有編譯 - 爲什麼?

javac quizServer.java quizServer.java:2: error: package org.acplt.oncrpc does not exist import org.acplt.oncrpc.*;^quizServer.java:3: error: package org.acplt.oncrpc.server does not exist import org.acplt.oncrpc.server.*;^quizServer.java:5: error: package uk.ac.hw.quizgame does not exist import uk.ac.hw.quizgame.Game; 
         ^quizServer.java:9: error: cannot find symbol public class quizServer extends quizServerStub { 
           ^ symbol: class quizServerStub quizServer.java:12: error: cannot find symbol 
     public quizServer() throws OncRpcException, IOException { 
           ^ symbol: class OncRpcException location: class quizServer quizServer.java:17: error: method does not override or implement a method from a supertype 
     @Override 
     ^quizServer.java:23: error: method does not override or implement a method from a supertype 
     @Override 
     ^quizServer.java:31: error: method does not override or implement a method from a supertype 
     @Override 
     ^quizServer.java:37: error: method does not override or implement a method from a supertype 
     @Override 
     ^quizServer.java:43: error: method does not override or implement a method from a supertype 
     @Override 
     ^quizServer.java:53: error: cannot find symbol 
         server.run(); 
          ^ symbol: method run() location: variable server of 

型quizServer 11個錯誤

但我不明白爲什麼這是造成錯誤?我沒有在eclipse IDE中看到這些錯誤,爲什麼他們出現在這裏?

真的很抱歉如果這是一個愚蠢的問題。我很少使用命令來編譯,但在這種情況下,我需要一個命令來運行我的服務器代碼,另一個命令在同一臺計算機上運行我的客戶端。

回答

1
package uk.ac.hw.quizgame does not exist import uk.ac.hw.quizgame.Game; 

您的應用程序中是否包含此名稱?如果沒有(或)刪除相關代碼(或),則需要將相應的jar添加到classpath中。

+0

我已刪除了(因爲我並不真的需要它),但我仍然得到錯誤,可能是因爲這個類,我試圖編譯擴展在同一個包已經存在的類。我如何一起編譯同一個包中的所有類,就像Eclipse一樣? – Chucky

+1

我不認爲這是可能的。 – kosa

相關問題