Q:

How could I run java class in command line for a intellij project

When I change dir to hw1/out/production/hw1/com/poc and run java Main
It gave me Error: Could not find or load main class Main

A:

You have to run java com.poc.Main from hw1/out/production/hw1/

