Usage
This page describes how to use the JBang extension for Visual Studio Code to work with Java scripts.
Completion
-
Directive Completion: Start typing
//
at the top of your Java file to get completions for JBang directives like//DEPS
,//SOURCES
, etc. -
Dependency Completion: In a
//DEPS
line, start typing a Maven group or artifact (e.g.,org.apache.commons:
) and pressCtrl+Space
(orCmd+Space
on Mac) to trigger completion for Maven artifacts and versions. -
Catalog Completion: In
jbang-catalog.json
, get completion for script references and aliases.
Running and Debugging
-
Use the codelens links ("Run JBang" or "Debug JBang") that appear above the main method or class declaration in your script.
-
You can also right-click a script file and select
Run JBang
orDebug JBang
from the context menu.
Dependency Management
-
When you edit
//DEPS
lines, the classpath is automatically updated for the script. -
To synchronize dependencies explicitly, right-click the script and select
JBang > Synchronize JBang
.
Script Templates
-
Use the command palette (
Ctrl+Shift+P
orCmd+Shift+P
) and runJBang: Create a new script
to start a new script from a template.
Advanced Usage
-
Install as Application: Right-click a script and select
JBang > install application
to add it to your PATH.
Tips
-
If completions or classpath updates do not work as expected, try running
Java: Clean Java Language Server Workspace
from the command palette and reload the window. -
For more information, see the project README or the JBang documentation.