简体   繁体   English

我有一个 Java 问题 - 它没有找到一些 package 或类

[英]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.但我对 Java 很陌生,任何建议将不胜感激。

My goal is to make my Main class to call the method from the second class.我的目标是让我的 Main class 调用第二个 class 的方法。

Main Class code:主要Class代码:

package Constructors;

public class Main {

    public static void main(String[] args) {

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

    }
}

Second Class code:第二个Class代码:

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 java文件中只能有一个public class,新建一个文件测试class,然后尝试运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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