From c14b68ffb99ee2fc4e10263652be45bbdaac1be8 Mon Sep 17 00:00:00 2001 From: Vitor Henrique <87824454+vitorhcl@users.noreply.github.com> Date: Wed, 10 Jan 2024 00:47:37 -0300 Subject: [PATCH] jbang: add page (#12030) * jbang: add page --------- Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> Co-authored-by: K.B.Dharun Krishna --- pages/common/jbang.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pages/common/jbang.md diff --git a/pages/common/jbang.md b/pages/common/jbang.md new file mode 100644 index 000000000..10fa98613 --- /dev/null +++ b/pages/common/jbang.md @@ -0,0 +1,37 @@ +# jbang + +> Easily create, edit and run self-contained source-only Java programs. +> See also: `java`. +> More information: . + +- Initialize a simple Java class: + +`jbang init {{path/to/file.java}}` + +- Initialize a Java class (useful for scripting): + +`jbang init --template={{cli}} {{path/to/file.java}}` + +- Use `jshell` to explore and use a script and any dependencies in a REPL editor: + +`jbang run --interactive` + +- Setup a temporary project to edit a script in an IDE: + +`jbang edit --open={{codium|code|eclipse|idea|netbeans|gitpod}} {{path/to/script.java}}` + +- Run a Java code snippet (Java 9 and later): + +`{{echo 'Files.list(Paths.get("/etc")).forEach(System.out::println);'}} | jbang -` + +- Run command line application: + +`jbang {{path/to/file.java}} {{command}} {{arg1 arg2 ...}}` + +- Install a script on the user's `$PATH`: + +`jbang app install --name {{command_name}} {{path/to/script.java}}` + +- Install a specific version of JDK to be used with `jbang`: + +`jbang jdk install {{version}}`