I'm not able to run a class file on the command line even though there are no problems with Java installation and path variables settings

I've been using Eclipse to practice programming Java for a while. Haven't got any problems so far, but today I just wanted to compile and run my code on the command line (I'm using Windows OS) and it's not working.

Suppose the compiled file name is 'Test.class'. After compiling, when I put 'java Test' on the command line then error message says, "couldn't find or load main class Test"

But I have set all the system variables like %JAVA_HOME%, Path, CLASSPATH and had no problems running that code on Eclipse.

Below are screenshots of my setting information on the command line. (Please ignore the Korean words)

system variables system variables

when I entered 'java' on the command line when I entered 'java' on the command line

when I entered 'javac' on the command line when I entered 'javac' on the command line

checking java version checking java version

No Problems, Right? But the error occurred, when I entered 'java Test' to run this code after compiling Test.java to Test.class (The letters you can't understand is Korean, ignore it, it says "couldn't find or load main class Test") Error, when I entered 'java Test' after compiling Test.java to Test.class

Help me Please!

------------------Below is additional screenshot----------------------- ... Can you see? I compiled TestClass.java and converted it into TestClass.class but when I executed "java TestClass", the error appears. enter image description here

Below is my code..... I did almost nothing on the code, just wanted to test command line method....

TestClass.java

package test;

public class TestClass {

    public static void main(String[] args) {
        System.out.println("SOS");
    }

}
Jon Skeet
people
quotationmark

The problem is your CLASSPATH environment variable. It exists, but doesn't include the current directory.

Unless you really need the CLASSPATH environment variable for some reason, I would remove it - then it will default to just the current directory. All the framework classes are already on the boot classpath - you don't need to worry about those.

If for some reason you can't change your environment variables, just specify the classpath on the command line:

java -cp . TestClass

people

See more on this question at Stackoverflow