Skip to content

Instantly share code, notes, and snippets.

@graemerocher
Created May 31, 2021 18:47
Show Gist options
  • Select an option

  • Save graemerocher/57a351a606e923655b199389fc3e3a33 to your computer and use it in GitHub Desktop.

Select an option

Save graemerocher/57a351a606e923655b199389fc3e3a33 to your computer and use it in GitHub Desktop.
Micronaut JBang Example
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.micronaut:micronaut-bom:2.5.4@pom
//DEPS io.micronaut:micronaut-http-server-netty
//DEPS io.micronaut:micronaut-inject-java
//DEPS org.slf4j:slf4j-simple
package app;
import io.micronaut.http.annotation.*;
import io.micronaut.runtime.Micronaut;
public class App {
public static void main(String... args) {
Micronaut.run(args);
}
}
@Controller("/hello")
class HelloController {
@Get("/")
String hello() {
return "Hello world";
}
}
@msgilligan
Copy link

Hi @graemerocher! Thanks for this example. I have updated it to work with Micronaut 4.10.3 and Java 21, but was unable to get it to work with Java 25 due to changes in how annotation processing works (I didn't try very hard.) See my fork for the changes:

https://gist.github.com/msgilligan/c18ebfa6395db858403bdaa77063d554/revisions?diff=split&w#diff-a24b52d9ef0a7124c3abcf1fee9e1e8e28ffdd61150415e23081f903000c9038

@msgilligan
Copy link

p.s. I was inspired by @maxandersen 's 2026: The Year of Java in the Terminal blog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment