Java fails to load a simple HelloWorld example on my PC(Windows 10, Java 8). I cannot find any system environmental changes that may cause this problem.
HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!!!");
}
}
Command Prompt
D:\Temp>javac HelloWorld.java
D:\Temp>java -classpath . HelloWorld
Error: Cound not find or load main class helloworld.
D:\Temp>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_261
D:\Temp>where java
C:\Program Files\Java\jdk1.8.0_261\bin\java.exe
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\Windows\System32\java.exe
D:\Temp>dir HelloWorld.*
2022-07-14 am 09:38 429 HelloWorld.class
2022-07-14 am 09:37 131 HelloWorld.java
The same class file works without problem in a test server (CentOS 7, Java 8).
$ java -classpath . HelloWorld
Hello, World!!!
One strange thing is that the class name in lowercase works well like the following:
helloworld2.java
public class helloworld2 {
public static void main(String[] args) {
System.out.println("Hello, World 2!!!");
}
}
Command Prompt
D:\Temp>javac helloworld2.java
D:\Temp>java helloworld2
Hello, World 2!!!
Could anybody help me to find a resolution?
Edit After Post
I remember that the system was automatically rebooted (maybe for update) before the problem started.
The problem continued after system reboot but disappered after system shutdown and then boot.