Hi, I am new to java and eclipse. I am trying to do the following : I have 2 files : main server.java import java.io.FileReader; import java.io.IOException; import java.net.ServerSocket; import java.util.Properties;
public class MainServer {
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { FileReader cfgFile = new FileReader("bin\\cfg\\mainserver.cfg"); Properties MainServerProperties = new Properties(); int socket = 0; try { MainServerProperties.load(cfgFile); String strSocket = MainServerProperties.getProperty("socket"); socket = Integer.parseInt(strSocket); System.out.println("the server socket is " + socket); } catch (IOException e) {
System.err.println("Could not read file " + cfgFile); System.exit(-1); } ServerSocket serverSocket = null; boolean listening = true; try { serverSocket = new ServerSocket(socket); while (listening) { MainServerThread thread = new MainServerThread(serverSocket.accept()); thread.start(); } } catch (IOException e) { System.err.println("Could not listen on port: " + socket); System.exit(-1); }
}
}
mainserverthread.java import java.net.Socket;
public class MainServerThread {
public MainServerThread(Socket incoming) { // TODO Auto-generated constructor stub m_incomingSocket = incoming; } public void start() { System.out.println("Accepting data from socket" + m_incomingSocket); } Socket m_incomingSocket; }
when I hit the line : MainServerThread thread = new MainServerThread(serverSocket.accept());
I get not found class exception. Any ideas ?
I am using windows XP service pack 3 eclipse build : 20090920-1017
> I have 2 files : > main server.java : > public class MainServer { : > mainserverthread.java : > public class MainServerThread
The two files should be called MainServer.java and MainServerThread.java respectively. The file names must match the class names (no spaces and case sensitive).