I've the java class:
package com.server.main;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class Main {
public static void main(String args[]) throws Exception{
ServerSocket server = new ServerSocket(12345);
Socket client = server.accept();
PrintWriter writer = new PrintWriter(client.getOutputStream());
writer.write("Hello from server");
}
}
Now I'm trying to compile and run it. What I do is:
javac Main.java
It's OK, Main.class
is produced.
Now, according to that post, I was trying to run that program:
java -cp C:\Users\workspace\Tests\src\com\server\main Main
java -cp C:\Users\workspace\Tests\src\com\server\main Main.class
java -cp . Main
java -cp . Main.class
All these produce the output:
Error: Could not find or load main class Main
What's wrong?