Editing
You can edit your script in an IDE/editor by using jbang edit helloworld.java
.
jbang edit helloworld.java
or
jbang edit . helloworld.java
By default 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.
jbang edit --open=[editor] helloworld.java
If your IDE does not support JBang style project you can use "sandbox" (-b
) mode where jbang
will generate a project in a temporary location with symbolic links to your script and open a editor.
Finally you can also if you prefer to call the editor/IDE yourself in a shell that supports variable evaluation specify --no-open
to tell JBang to not open an editor.
code `jbang edit --no-open 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.
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.
|
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 Support
Some IDE’s have dedicated JBang support and jbang edit
assumes your IDE has this support installed.
If your IDE does not support JBang directly you can use "sandbox" mode a temporary project is created with symoblic links and a project setup that works in most Java based IDE’s. This is useful for single file scripts. If you have multiple files we highly recommend to use a IDE that have JBang plugin.
The following IDE’s have dedicated support (at time of writing):
Sandbox edit support
The sandbox edit -b
feature using temporary directory and symbolic links been tested with the following IDE’s:
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: