TextText-based

text/x-java-source

Java Source

Reference for text/x-java-source, the MIME type for Java programming language source code files.

MIME Type Detector

Drop a file to detect its MIME type — no upload, runs in your browser

📄

Drop any file here or click to choose

Expected extensions: .java

HTTP Content-Type Header

HTTP Header
Content-Type: text/x-java-source; charset=utf-8

Associated File Extensions

.java

Quick Facts

MIME Typetext/x-java-source
CategoryText
TypeText-based (human-readable)
Extensions.java

Common Usage

Java source files are compiled to bytecode that runs on the JVM. Java is used for enterprise applications, Android development, web servers (Spring Boot), big data (Hadoop, Spark), and financial systems.

This MIME type identifies uncompiled Java source code.

Code Examples

HTML
<!-- Link or embed with explicit type -->
<link rel="stylesheet" href="file.java" type="text/x-java-source">

<!-- Or for script/media elements -->
<script type="text/x-java-source" src="file.java"></script>
Node.js
// Express.js
app.get('/file', (req, res) => {
  res.type('text/x-java-source');
  res.send(data);
});

// Node.js http
res.writeHead(200, { 'Content-Type': 'text/x-java-source' });
nginx
# nginx.conf — add to types block or use default
types {
    text/x-java-source  java;
}

# Or set for a specific location
location /api/ {
    default_type text/x-java-source;
}

Related MIME Types

More Text MIME Types

Other text types in the Text family

Related Tools

Explore More MIME Types

Browse our complete reference of 185 MIME types with usage examples, HTTP headers, and code snippets.