我的文件中有以下代码
Hello.java
package hello_project;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
代码在我运行时有效:
java Hello
但是当我使用时代码不起作用:
javac Hello.java
java Hello
错误信息是:
class not found wrong class name
> type Hello.java
package hello_project;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
> javac -d . Hello.java
> dir hello_project
...
Directory of C:\...\hello_project
06/14/2024 02:12 PM <DIR> .
06/14/2024 02:12 PM <DIR> ..
06/14/2024 02:12 PM 429 Hello.class
1 File(s) 429 bytes
2 Dir(s) 15,829,270,528 bytes free
> java -cp . hello_project.Hello
Hello world