Skip to content
Discussion options

You must be logged in to vote

(Answering my own question; mainly so that others who encounter the same problem find this solution.)

By default JBang runs Java code in Markdown files using JDK's JShell, which executes the lines separately instead of recognizing it as a single statement wrapped across multiple lines.

This can be worked around by adding an explicit main method (and using a recent JBang version which includes #2592, such as 0.141.0). JBang will then compile the code as regular Java code instead of as JShell snippet and wrapped statements are properly supported.

Because JBang concatenates all code snippets in the file to one Java program and because most Markdown viewers support a subset of HTML, the main …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Marcono1234
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant