简体   繁体   中英

I have a Java Problem - It is not locating some package or classes

I create just a test over here to try to see what is the problem. But I am very new to Java, Any advice will be much appreciated.

My goal is to make my Main class to call the method from the second class.

Main Class code:

package Constructors;

public class Main {

    public static void main(String[] args) {

        test testObject = new test();
        testObject.message();

    }
}

Second Class code:

package Constructors;

public class test {

    public void message() {
        System.out.println("Please Work!");
    }
}


Error msg:

"C:\Users\Hristiyan Dimov\.jdks\openjdk-15.0.2\bin\java.exe" "-javaagent:D:\PROGRAMS\JAVA-InteliJ IDEA\IntelliJ IDEA Community Edition 2020.3.2\lib\idea_rt.jar=53870:D:\PROGRAMS\JAVA-InteliJ IDEA\IntelliJ IDEA Community Edition 2020.3.2\bin" -Dfile.encoding=UTF-8 Constructors.Main
Error: Could not find or load main class Constructors.Main
Caused by: java.lang.ClassNotFoundException: Constructors.Main

Process finished with exit code 1

图像显示“运行”过程后程序的结束屏幕

There can be only one public class in java file, create another file for test class and then try to run it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM