Error: Could not find or load main class Main

前端 未结 3 1447
天命终不由人
天命终不由人 2020-12-12 02:01

I\'ve the java class:

package com.server.main;

import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Main {
    pu         


        
3条回答
  •  春和景丽
    2020-12-12 02:26

    Your Main is in a package, I believe you need

    java -cp C:\Users\workspace\Tests\src com.server.main.Main
    

    You might also move to the top folder of your project and use . like

    cd C:\Users\workspace\Tests\src
    java -cp . com.server.main.Main
    

    Finally, you could add that folder to your CLASSPATH like

    set CLASSPATH=C:\Users\workspace\Tests\src
    java com.server.main.Main
    

提交回复
热议问题