I do not know why it cannot found main class. In fact, I use terminal to run this, it works.
Asked
Active
Viewed 587 times
-1

Niklas Rosencrantz
- 25,640
- 75
- 229
- 424

Eve_ltz
- 21
- 2
-
5You're trying to run a class called `Test` but your class name is `HelloWorld`... – Reimeus Jun 09 '17 at 17:45
-
See also http://stackoverflow.com/a/42660624/104891. – CrazyCoder Jun 09 '17 at 18:07
1 Answers
1
The error message is more precisely:
Error: Could not find or load main class Test
Emphasis mine. In the top-right corner, notice the dropdown labeled "Test", with a small red cross on it. That's the currently active run configuration. It's a previous configuration that you used that's no longer valid.
An easy way to run this program is using keyboard shortcuts:
- Place the cursor inside the
main
method - Press Control Shift F10 at the same time
This will create a new run configuration, to execute the class you are currently in. After this is done, observe the label on the dropdown in the top-right corner change to "HelloWorld", the name of your class.

janos
- 120,954
- 29
- 226
- 236