You can edit your script in an IDE/editor by using jbang edit helloworld.java. This will generate a project in a temporary location with symbolic links to your script and output the generated folder name. The easiest way to use that is to use it in a call to your IDE:

code `jbang edit helloworld.java`

If you add further dependencies to your file just re-run the edit command and the relevant files will be regenerated with the updated dependencies.

Above does require using a shell that allows for variable evaluation, if you are on i.e. Windows then you might prefer using:

jbang edit --open=[editor] helloworld.java

The editor used will be what is specified as the argument to --open or value of JBANG_EDITOR environment variable. The editor command must be available on the PATH to be executed from jbang. If you are executing jbang edit --open=code helloworld.java a code executable (visual studio code) must be on the PATH. Next to this you can pass the full path to the open parameter like in --open=/usr/bin/code.

On Windows you might need elevated privileges to create symbolic links. If you don’t have permissions then the edit option will result in an error. To use it enable symbolic links for your user or run your shell/terminal as administrator to have this feature working.

Install of default vscodium editor [EXPERIMENTAL]

If no editor available at all jbang will offer to install VSCodium (free/libre version of Visual Studio code) with default java extensions enabled in so called "portable mode". Portable mode means all the installed binaries and configuration does not affect rest of your system; everything is stored in ~/.jbang/editor.

This automatic install and setup of editor is fully optional and if you have another IDE or editor already installed use it using jbang edit --open=<editor> or set JBANG_EDITOR environment variable to have jbang use it by default.

Live Editing

You can also use jbang edit --live and jbang will launch your editor while watching for file changes and regenerate the temporary project to pick up changes in dependencies.

IDE and Editor support

The edit feature been tested with the following IDE’s:

Table 1. IDE’s and Editors tested with jbang

50 Visual Studio Code

50 Eclipse

50 IntelliJ Idea

50 Apache NetBeans

50 Neovim w/ spacevim Java

50 Emacs w/ Spacemacs Java

The edit feature works with various IDE’s - it generates a build.gradle to use with IDE’s that understands Gradle directly. For speed and consistency jbang also generates IDE specific settings.

Currently launchers and project files are generated for Eclipse and vscode. Intellij just reads build.gradle for now thus to run/debug you will need to manually set it up.

Some editors like Code or IDEA are not per default executable / startable from the command line. Here are some helpfull documentations for supporting command line usage of different editors: