title: Running a Java program without compiling
body: <p>Recently, I installed Java 11. When coding, accidentally, instead of compiling <code>Main.java</code> with <code>javac Main.java</code>, I wrote <code>java Main.java</code>. It did not show me any errors and worked out without any issues. Why did this happen? Is this a new feature in newer versions of Java?</p>
  <p>Contents of <code>Main.java</code>:</p>
  <pre><code>public class Main {
      public static void main(String[] args) {
          System.out.println(&quot;Hello, World!&quot;);
      }
  }
  </code></pre>
  <p>Running in Java 8:</p>
  <pre><code>java version &quot;1.8.0_112&quot;
  Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
  Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
  
  &gt;&gt;&gt; java Main.java
  Error: Could not find or load main class Main.java
  </code></pre>
  <p>Running in Java 11:</p>
  <pre><code>java version &quot;11.0.1&quot; 2018-10-16 LTS
  Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
  Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
  
  &gt;&gt;&gt; java Main.java
  Hello, World!
  </code></pre>