DevToolsmith

JAR MIME Type

application/java-archive is the MIME type for Java archives (.jar). Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
application/java-archive
Extensions
.jar
Content-Type header
application/java-archive
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Programs and binaries

About Java archive files

A ZIP file of compiled classes and resources, with a manifest at META-INF/MANIFEST.MF. Maven repositories serve JARs with this type; application/x-java-archive also appears.

Other types seen for these files: application/x-java-archive . Accept them when reading uploads, but send application/java-archive yourself.

File signature

JAR files start with 50 4B 03 04 ("PK", a ZIP archive). The extension and the type a browser reports for an upload both come from the file name, so check these bytes on the server before trusting a file.

Serve .jar with the right Content-Type

Response header
Content-Type: application/java-archive
nginx (a line in the types { } block of mime.types)
application/java-archive jar;
Apache (.htaccess or server config)
AddType application/java-archive .jar
Caddy
@jar path *.jar
header @jar Content-Type "application/java-archive"
Check what a server sends
curl -sI https://example.com/file.jar | grep -i '^content-type'
# Content-Type: application/java-archive

Set the type in code

Node.js (Express)
res.set('Content-Type', 'application/java-archive');
// Or make the browser download it:
res.attachment('file.jar');
Python
import mimetypes

mimetypes.add_type('application/java-archive', '.jar')  # if your system doesn't know it
mimetypes.guess_type('file.jar')[0]  # 'application/java-archive'
Go
mime.AddExtensionType(".jar", "application/java-archive")
w.Header().Set("Content-Type", "application/java-archive")

Accept .jar uploads

HTML
<input type="file" accept=".jar,application/java-archive">

The accept attribute only filters the file picker; users can still choose another file. Listing the extension as well as the type matters, because operating systems don’t always report the type you expect.

Related types

  • .zip (application/zip): ZIP archive
  • .apk (application/vnd.android.package-archive): Android package
  • .bin (application/octet-stream): Binary data

More programs and binaries

.exe . Look up any extension or type with the MIME type lookup.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is the MIME type for .jar files?

application/java-archive. You may also see application/x-java-archive, which is older or unofficial; send application/java-archive. The full header is "Content-Type: application/java-archive".

Why does my server send the wrong Content-Type for .jar?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .jar is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".

How can I check that a file really is JAR?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. JAR files start with 50 4B 03 04 ("PK", a ZIP archive). The MIME type lookup on this site reads them for you when you drop a file on it.