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
//DEPSline, start typing a Maven group or artifact (e.g.,org.apache.commons:) and pressCtrl+Space(orCmd+Spaceon 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 JBangorDebug JBangfrom the context menu.
Dependency Management
-
When you edit
//DEPSlines, 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+PorCmd+Shift+P) and runJBang: Create a new scriptto start a new script from a template.
Advanced Usage
-
Install as Application: Right-click a script and select
JBang > install applicationto add it to your PATH.
Tips
-
If completions or classpath updates do not work as expected, try running
Java: Clean Java Language Server Workspacefrom the command palette and reload the window. -
For more information, see the project README or the JBang documentation.