我正在用Java编写多线程代理服务器应用程序,并且不断出现此错误。我在做什么错了?
这是我ProxyApp.java文件类中的代码
/**
* Listens to port and accepts new socket connections.
* Creates a new thread to handle the request and passes it the socket connection and continues listening.
*/
public void listen(){
while(running){
try {
// serverSocket.accept() Blocks until a connection is made
Socket socket = serverSocket.accept();
// Create new Thread and pass it Runnable RequestHandler
RequestHandler request = new RequestHandler(socket);
Thread thread = new Thread(request);
// Key a reference to each thread so they can be joined later if necessary
servicingThreads.add(thread);
thread.start();
} catch (SocketException e) {
// Socket exception is triggered by management system to shut down the proxy
System.out.println("Server closed");
} catch (IOException e) {
e.printStackTrace();
}
}
}
所引用的RequestHandler.java文件类中的函数
/**
* Creates a RequestHandler object capable of servicing HTTP(S) GET requests
* @param clientSocket socket connected to the client
*/
public RequestHandler(Socket clientSocket){
this.clientSocket = clientSocket;
try{
this.clientSocket.setSoTimeout(2000);
proxyToClientBr = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
proxyToClientBw = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
}
catch (IOException e) {
e.printStackTrace();
}
}
我在终端上遇到的错误
MacBook-Pro-de-Marcos:mwmv marcosvicente$ javac RequestHandler.java
MacBook-Pro-de-Marcos:mwmv marcosvicente$ javac proxyApp.java
proxyApp.java:10: error: cannot find symbol
import ru.novsu.povt.mwmv.RequestHandler;
^
symbol: class RequestHandler
location: package ru.novsu.povt.mwmv
proxyApp.java:122: error: cannot find symbol
RequestHandler request = new RequestHandler(socket);
^
symbol: class RequestHandler
location: class proxyApp
proxyApp.java:122: error: cannot find symbol
RequestHandler request = new RequestHandler(socket);
^
symbol: class RequestHandler
location: class proxyApp
3 errors