Red Hat Bugzilla – Bug 1195203
openjdk 6: MimetypesFileTypeMap no default mime.types
Last modified: 2016-05-10 16:29:54 EDT
Description of problem:
Trying to get mime type of files with MimetypesFileTypeMap.getDefaultFileTypeMap()  results in always returning "application/octet-stream" regardless of file type or extension.
I couldn't find any default mime.types file used by java. So I tried a workaround:
> ln -s /etc/mime.types ~/.mime.types
And it starts to work. I IMO the openjdk package should be modified to take default mime.types from /etc/mime.types and then search in other locations for the file.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. use the following groovy script:
2. $ groovy mime-type.groovy /tmp/test.html
The same issue does not exist in openjdk 1.8 as shipped with fedora 21. So it must have been fixed somehow in later versions.
Confirmed; the bug is present on 6 & 7, but not 8.
$ /usr/lib/jvm/icedtea-6/bin/java RH1195203 ~/projects/httpdocs/redirect.html
$ /usr/lib/jvm/icedtea-7/bin/java RH1195203 ~/projects/httpdocs/redirect.html
$ /usr/lib/jvm/icedtea-8/bin/java RH1195203 ~/projects/httpdocs/redirect.html
There are files missing from resources.jar in 6 & 7, presumably due to some mistake during the old build process.
$ ls resources-7/META-INF/
$ ls resources-8/META-INF/
mailcap.default MANIFEST.MF mimetypes.default services/
There are two parts to fixing this:
1. Fix the build bug which is preventing /META-INF/mimetypes.default and other files being included in resources.jar
2. Make use of the mime.types supplied by mailcap which is more comprehensive and e.g. allows Java to recognise Java source files.
Part 2 is done and that resolves this issue. The missing default file should be resolved upstream.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.