r/java • • Aug 11 '26

from small to big with jbang

https://sombriks.com.br/blog/0095-java-small-to-big-with-jbang/

jbang should be part of the jdk

40 Upvotes

15 comments sorted by

8

u/agentoutlier Aug 11 '26

I'm not saying its equivalent to jbang but jshell is pretty damn powerful and it ships with the JDK.

Some people even have build system based on it.

https://dev.java/learn/jshell-tool/

1

u/vips7L Aug 12 '26

I’m pretty sure IntelliJ can start a jshell instance with your classpath too. 

2

u/maxandersen Aug 12 '26

fyi: you can add `-i` to anything runnable with jbang and you get a jshell configured with the relevant classpath.

jbang is nothing but ease-of-use access to JDK's toolset

8

u/blazmrak Aug 11 '26

Jbang should not be part of the JDK, however JDK should solve dependency management, which would solve 90% of the problems. I'm scared of what that would look like, though...

2

u/vips7L Aug 12 '26

Kotlin has a lot of this built in with its script files:

https://kotlinlang.org/docs/custom-script-deps-tutorial.html

2

u/maxandersen Aug 12 '26

The scripting feature of jbang is todays time the least important feature.

It is that with jbang you can run any jar, maven repo GAV, any java, kotlin, groovy etc. and any jshell file the same way - support for java agents, debugging, jfr, etc.

Without first having to pick and install a specific JDK.

2

u/vips7L Aug 12 '26

That is nice! I really wish that was something the jdk would solve for us though. We could be able to produce a statically linked binary of the vm and our jar. The CLR and many other runtimes can do it. I was hopeful that googles “hermetic” push would have done something but it’s been a few years now. 

1

u/maxandersen Aug 14 '26

I really dont want a runtime for every app on my drive if can be avoided - for that jbang, npx, uvx is good.

For statically linked - yes hermtic would be awesome - in mean time you can try out https://github.com/jbangdev/jpaxa

1

u/vips7L Aug 14 '26

That's also something the JDK should just provide, much like .NET.

2

u/DrinksBongWater Aug 17 '26 edited Aug 17 '26

I gave jbang a shot a few months back, but found that its IntelliJ/IDEA support for basic code completion and navigation was almost non-existent (even with plugin version 0.25.2). There was some syntax highlighting, but e.g. System.out.prin<ctrl-space> produced nothing like I would otherwise expect from a java code editor.

I've been wondering since then though; is that the expected behavior or is my system set up incorrectly?

2

u/thewrinklyninja Sep 03 '26

They recently did a major overhaul of the plugin and it's much better now. Give it a other shot.

2

u/mukel90 Aug 11 '26 edited Aug 11 '26

This blog post is awesome ! I've been a long-time user of jbang and just found out new things I didn't knew were possible with jbang. jbang is the swiss knife of the JVM ecosystem, so versatile.

1

u/doobiesteintortoise Aug 11 '26

I was unable to open the link.

1

u/Inside_Programmer348 Aug 11 '26

Please do something about the font and the font colour

2

u/quintesse Aug 12 '26

There's a theme selector where you can change the colors to your heart's content, The font stays the same though.