[JAVA rookie] encountered the problem that the main class could not be found or could not be loaded when dealing with package

The

code is as follows:
the first paragraph of code:

package cn.kgc.pack1;
import java.util.Scanner;
public class Person {      //"" 

    private int age;
    private String name;
    private String gender;
    
    public Person() {
        this.name = "";
    }

    public Person(String name) {
        this.name = name;
    }
    
    public String setName(String name) {
        return this.name;
    }

    public String setGender(String gender) {
        return this.gender;
    }

    public int setAge(int age) {
        return this.age;
    }


    public void say() {
        System.out.println("\r\n :" + this.name + "\r\n:" + this.gender + 
                "\r\n:" + this.age + "" );
    }

}

second paragraph of code:

package cn.kgc.pack2;
import cn.kgc.pack1.Person;
public class PersonTest {
    public static void main(String[] args) {
        Person hanbing = new Person();
        hanbing.setName("");
        hanbing.setGender("");
        hanbing.setAge(22);
        //hanbing.work();

        hanbing.say();
        //hanbing.work("");
    }
}
The

code is not the point. I compiled both pieces of code successfully and put them in two different packages. The path to the package is as follows:

clipboard.png
mainPersonTest:

clipboard.png
Why on earth is this?
my code is copied from the textbook, and the compilation is also passed. In theory, if you put it in the same folder, it should be able to run, but it will fail if you put it in a different package.

Apr.23,2021

1. Execute the command in the base directory
2. Command: java cn.kgc.PersonTest

Note: compilation command javac com/kgc/PersonTest.java with directory separator is different from running command

Menu