title: Adding Mimetypes to MimetypesFileTypeMap
body: <p>I'm having trouble adding Mimetypes to MimetypesFileTypeMap. I've tried adding a META-INF/mime.types file just like the <a href="http://www.gnu.org/software/classpathx/jaf/javadoc/javax/activation/MimetypesFileTypeMap.html" rel="noreferrer">Documentation</a> says to. but it doesn't seem like it is getting read by MimetypesFileTypeMap.</p>
  <p>Am I missing something?</p>
  <p>It is a Spring/Maven Web project. Any help would be appreciated!</p>
  <hr />
  <p>Even stranger side point.  A passerby (Andrew T.) was doing some investigation into MIME types just the other day &amp; uncovered this documentation in the <code>MimetypesFileTypeMap</code> JavaDocs.</p>
  <hr />
  <h2>MIME types file search order:</h2>
  <p>The <code>MimetypesFileTypeMap</code> looks in various places in the user's system for MIME types file entries. When requests are made to search for MIME types in the <code>MimetypesFileTypeMap</code>, it searches MIME types files in the following order:</p>
  <ol>
  <li>Programmatically added entries to the <code>MimetypesFileTypeMap</code> instance.</li>
  <li>The file <code>.mime.types</code> in the user's home directory.</li>
  <li>The file <code>&lt;java.home&gt;/lib/mime.types</code>.</li>
  <li>The file or resources named <code>META-INF/mime.types</code>.</li>
  <li>The file or resource named <code>META-INF/mimetypes.default</code> (usually found only in the <code>activation.jar</code> file). <strong>(A)</strong></li>
  </ol>
  <p><strong>(A) As demonstrated by the <a href="https://stackoverflow.com/questions/6308142/adding-mimetypes-to-mimetypesfiletypemap/6333057#6333057">code posted by jwrobel</a>, the Jar actually seems to be the <code>resources.jar</code> on at least two systems (with JDKs).</strong></p>
  <hr />
  <p>So given this source..</p>
  <pre><code>import java.io.File;
  import javax.activation.MimetypesFileTypeMap;
  
  class TestMime {
      public static void main(String[] args) {
          System.out.println(System.getProperty(&quot;java.version&quot;));
  
          File f = new File(System.getProperty(&quot;java.home&quot;), &quot;lib&quot;);
          f = new File(f, &quot;mime.types&quot;);
          System.out.println(f.exists() + &quot; \t - &quot; +f);
  
          f = new File(System.getProperty(&quot;user.home&quot;), &quot;.mime.types&quot;);
          System.out.println(f.exists() + &quot; \t - &quot; +f);
  
          MimetypesFileTypeMap mfm = new MimetypesFileTypeMap();
          System.out.println(mfm.getContentType(&quot;a.js&quot;));
          System.out.println(mfm.getContentType(&quot;a.png&quot;));
          System.out.println(mfm.getContentType(&quot;a.jpg&quot;));
          System.out.println(mfm.getContentType(&quot;a.au&quot;));
          System.out.println(mfm.getContentType(&quot;a.htm&quot;));
      }
  }
  </code></pre>
  <p>..we can rule out '1' - programmatically added.  We can also forget 4 &amp; 5 if we run it from the command line in a directory with no <code>META-INF</code>, no <code>activation.jar</code> on the class-path.  Which only leaves options 2 &amp; 3.</p>
  <p>Yet the output of this source is..</p>
  <pre><code>1.6.0
  false    - C:\Program Files\Java\jdk1.6.0\jre\lib\mime.types
  false    - C:\Users\Andrew\.mime.types
  application/octet-stream
  application/octet-stream
  image/jpeg
  audio/basic
  text/html
  Press any key to continue . . .
  </code></pre>
  <p>I.E.  The <code>false</code> result on both files that could be the source of the MIME mappings shown for the file strings, suggest those last two source of info. don't exist.  So where the heck is the information coming from?</p>