The java command runs your program in the Source-File Mode if you are not running a .class file (Java Byte Code).
Using the Source-File Mode, you can do some weird stuffs like running a Java program with two public class, running .c, .png, .mp4, or any file with any extension and so much more.
I've discussed in details in a medium article. In the article, I ran a valid .pdf as a Java program. Also discussed about the Source-File mode, and what you can do with it.
Article link: https://medium.com/p/b3cc0bfa2527