This error occurs when executing commands with Java
localhost:SocketDemo wangwei$ javac Server.java localhost:SocketDemo wangwei$ java Server 6066错误: 找不到或无法加载主类 Server
if the JDK environment variable is configured correctly, the Java Javac java-version command can be identified.
cause of the error :
Using the Java command to run the class file directly, the file has a guide code line error. (using Java commands to run files directly in Ecplise is prone to such errors)
package SocketDemo;
Workaround :
Method 1: Remove the package socketdemo; Execute Javac and Java commands again
Method 2: Keep the package code line, create a Socketdemo directory under this directory, and copy the Server.java in.
localhost:SocketDemo wangwei$ javac SocketDemo/Server.java localhost:SocketDemo wangwei$ java SocketDemo/Server 6066等待远程连接,端口号为6066.....
Successfully solved!
Java could not find or load the main class