I want to be able to execute a java class from Command Prompt in windows without specifying the classpath explicitly every time I want to execute a java class, for example like this
where I execute the HelloWorld class in the "ExamplePackage" package.
I want to accomplish the same result without specifying the classpath, as follows
but this gives me an Error: Could not find or load main class HelloWorld
. As I understand it, this error is caused by java not being able to locate the class since classpath has not been specified.
Now, I want to solve this problem by setting a global variable classpath value to C:\Users\UpdatusUser\Desktop\ExampleProject
.
This can be accomplished, as I understand, over here
But that does not seem to solve the issue, since I still get the following result if I now use java ExamplePackage.HelloWorld
What am I doing wrong?