<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/scripting-java-11-shebang-and-all-yst95hl6v" -->

---
title: Scripting Java 11, Shebang And All | daily.dev
description: Java 11 introduced single-source-file execution, allowing you to run a .java file directly with the `java` command without a separate compilation step. Beyond...
canonical: https://daily.dev/posts/scripting-java-11-shebang-and-all-yst95hl6v
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Scripting Java 11, Shebang And All | daily.dev
og:description: Java 11 introduced single-source-file execution, allowing you to run a .java file directly with the `java` command without a separate compilation step. Beyond...
og:url: https://daily.dev/posts/scripting-java-11-shebang-and-all-yst95hl6v
og:image: https://api.daily.dev/og/posts/YST95hL6v.png
og:image:alt: Scripting Java 11, Shebang And All
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Scripting Java 11, Shebang And All

**[nipafx \(Nicolai Parlog\)](https://daily.dev/sources/nipafx)** · 10 min read · 0 upvotes · 0 comments

## Summary

Java 11 introduced single-source-file execution, allowing you to run a .java file directly with the `java` command without a separate compilation step. Beyond quick experimentation, this enables writing proper Unix scripts using a shebang line pointing to the Java binary. Key details include the `--source` flag for specifying Java version, support for preview features, argument passing, class loader behavior, and a practical echo script example demonstrating streams and stdin handling.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nipafx.dev/scripting-java-shebang>

## Similar posts on daily.dev

- [How to Use Java as a Scripting Language](https://daily.dev/posts/how-to-use-java-as-a-scripting-language-p0o7jgbrx) · Foojay.io · 25 upvotes · 2 comments
- [adam bien's blog](https://daily.dev/posts/adam-bien-s-blog-15pa9lpqa) · Adam Bien · 0 upvotes · 0 comments
- [Big things have small beginnings: taking Java from small to big with JBang](https://daily.dev/posts/big-things-have-small-beginnings-taking-java-from-small-to-big-with-jbang-lnktvm4hx) · Awesome Java Newsletter · 1 upvotes · 0 comments
- [Compile-Time Conditions in Java](https://daily.dev/posts/compile-time-conditions-in-java-kjy5rh792) · Baeldung · 0 upvotes · 0 comments
- [Show HN: Executable Markdown files with Unix pipes](https://daily.dev/posts/show-hn-executable-markdown-files-with-unix-pipes-u9qcwjh0b) · Hacker News · 0 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#jvm](https://daily.dev/tags/jvm)

[View this post on daily.dev](https://daily.dev/posts/scripting-java-11-shebang-and-all-yst95hl6v)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Scripting Java 11, Shebang And All","url":"https://daily.dev/posts/scripting-java-11-shebang-and-all-yst95hl6v","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/scripting-java-11-shebang-and-all-yst95hl6v"},"datePublished":"2026-03-16T08:14:00.842Z","dateModified":"2026-03-16T08:27:28.843Z","description":"Java 11 introduced single-source-file execution, allowing you to run a .java file directly with the `java` command without a separate compilation step. Beyond...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/29f4544b21934746ebdc2d74555b7ab5?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/29f4544b21934746ebdc2d74555b7ab5?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"nipafx (Nicolai Parlog)","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"nipafx (Nicolai Parlog)","logo":"https://media.daily.dev/image/upload/s--H_Echo_u--/f_auto,q_auto/v1773648772/logos/nipafx?_a=BAMAMiiu0","url":"https://daily.dev/sources/nipafx"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/scripting-java-11-shebang-and-all-yst95hl6v","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,jvm","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"nipafx (Nicolai Parlog)","item":"https://daily.dev/sources/nipafx"},{"@type":"ListItem","position":3,"name":"Scripting Java 11, Shebang And All"}]}
```

