简体   繁体   English

服务器端Java应用程序代码未编译-为什么?

[英]Server side Java application code not compiling - why?

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); }
    }

}

For the code above, I get the following from the compiler 对于上面的代码,我从编译器获得以下内容

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

type quizServer 11 errors 键入quizServer 11错误

But I don't see why this is causing errors? 但是我不明白为什么这会导致错误? I'm not getting these errors within the eclipse IDE, so why are they appearing here? 我在Eclipse IDE中没有得到这些错误,为什么它们会出现在这里?

Really sorry if this is a stupid question. 非常抱歉,如果这是一个愚蠢的问题。 I very rarely use command to compile, but I have to in this case as I need one command to run my server code, and another to run my client on the same machine. 我很少使用命令进行编译,但是在这种情况下,我必须这样做,因为我需要一个命令来运行服务器代码,而另一个则需要在同一台计算机上运行客户端。

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

Do you have package with this name in your application? 您的应用程序中是否有使用此名称的软件包? If not (or) remove relevant code (or) you need to add appropriate jars to classpath. 如果不是(或)删除相关代码(或),则需要向类路径中添加适当的jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM