In Java 9 you have REPL which allows you to write code by typing code fragments.
However, even though you don’t have to write all the code for a class
the code is wrapped in a class in reality.
0
solved Is it possible to run java program without class?