title: OpenJDK only: Why does getResourceAsStream() not return MANIFEST.MF in executable JAR
body: <p>I have a curious situation. My code does not load the <code>MANIFEST.MF</code> using <code>getResourceAsStream()</code> on OpenJDK 1.6. On Oracle JDK 1.6+ it works well. I came across this when I was accidently running my code on OpenJDK.</p>
  
  <p><strong>main() method:</strong></p>
  
  <pre><code>public static void main(String[] args) throws IOException {
  
      InputStream is = Main.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
      InputStreamReader isr = new InputStreamReader(is);
      char[] c = new char[2048];
      int read;
  
      StringBuffer b = new StringBuffer();
  
      while ((read = isr.read(c)) &gt; 0) {
          b.append(c, 0, read);
      }
  
      System.out.println(b.toString());
  }
  </code></pre>
  
  <p><strong>Maven JAR plugin definition:</strong></p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
      &lt;configuration&gt;
          &lt;archive&gt;
              &lt;manifest&gt;
                  &lt;mainClass&gt;net.noorg.test.Main&lt;/mainClass&gt;
                  &lt;addClasspath&gt;true&lt;/addClasspath&gt;
              &lt;/manifest&gt;
          &lt;/archive&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p><strong>Using OpenJDK 1.6:</strong></p>
  
  <pre><code>$ java -version
  java version "1.6.0_18"
  OpenJDK Runtime Environment (IcedTea6 1.8.7) (6b18-1.8.7-2~squeeze1)
  OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)
  $ java -jar target/test-load-resource-1.0-SNAPSHOT.jar
  Manifest-Version: 1.0
  Created-By: 1.6.0_18 (Sun Microsystems Inc.)
  </code></pre>
  
  <p><strong>Using Sun JDK 1.6:</strong></p>
  
  <pre><code>$ java -version
  java version "1.6.0_29"
  Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
  Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)
  $ java -jar target/test-load-resource-1.0-SNAPSHOT.jar
  Manifest-Version: 1.0
  Archiver-Version: Plexus Archiver
  Created-By: Apache Maven
  Built-By: ABC
  Build-Jdk: 1.7.0_07
  Main-Class: net.noorg.test.Main
  </code></pre>
  
  <ul>
  <li>Who's wrong - OpenJDK or I?</li>
  <li>Whats the reason for this?</li>
  <li>Is this only related to the Manifest or would this affect all resources?</li>
  </ul>
  
  <hr>
  
  <h1>Edit 1:</h1>
  
  <ul>
  <li>Both execution use the same .jar</li>
  <li>Maven is running on Oracle JDK 1.7</li>
  <li>I'm running a system with two JDKs installed "defining" them trough <code>JAvA_HOME</code> and <code>PATH</code></li>
  <li>I'm running the .jar on one machine using different <code>JAVA_HOME</code>'s set and <code>PATH</code>s set to <code>java</code> in two different consoles.</li>
  </ul>
  
  <h2>In addition to the above outputs</h2>
  
  <p><strong>Open JDK (alternative JAVA_HOME/PATH not set):</strong></p>
  
  <pre><code>$ echo "$JAVA_HOME" ; which java
  
  /usr/bin/java
  </code></pre>
  
  <p><strong>Sun JDK set:</strong></p>
  
  <pre><code>$ echo "$JAVA_HOME" ; which java
  /usr/local/jdk
  /usr/local/jdk/bin/java
  </code></pre>
  
  <hr>
  
  <h1>Edit 2:</h1>
  
  <p>If the <code>JAVA_HOME</code> is properly defined for the OpenJDK (by default) it's the same.</p>
  
  <pre><code>$ echo "$JAVA_HOME" ; which java
  /usr/java
  /usr/bin/java
  </code></pre>
  
  <p>So it's not related to the empty <code>JAVA_HOME</code> on my account.</p>