subtask2 = scope.fork(task2);
scope.join();
} catch (Exception e) {
e.printStackTrace();
}
}
?? Java ??? ???? ??? ????? ??? ? ????.
??? ??? ?? ??? ?? ??? ???? ??? ? ????.
-
jar ??: jbang import Portable helloworld.java. ????? ???? ???? ?? ?? ??? ???? ?? ? ????.
- A fatjar: ?? ???? ?????: jbang import fatjar helloworld.java. ? ??? ????? ?? ???? JDK/JRE? ???? ???. ?? ????? ?? ???? ? ?????.
- JDK? ???? jlink ????: jbang ???? jlink helloworld.java. ??? ????? Unix? helloworld-jlink/bin/helloworld ?? Windows? helloworld-jlink/bin/helloworld.bat???.
-
???? ???: jbang ???? ???? helloworld.java. ?? ???? GraalVM ??? ?????.
??? ???? ????? mavenrepo? ??? ?? ????. jbang import mavenrepo helloworld.java
JDK ??
?? ??? ? ??? Jbang? ???? JDK? ??? ? ????.
jbang jdk list? ???? ??? JDK? ????, jbang jdk list --available --show-details? ???? ??? ? ?? JDK? ????, jbang jdk install [version]? ???? ? JDK? ??? ? ????. Jbang? SDKMAN? ???? ???? ????? JDK? ???? ?? ?????.
?? ?????? JDK ??? ??? ?? ????.
?? ???? ??? ?? ?? ???? ?????. ??? ??? ??? ?? //JAVA [??], ??? ?? ??? ??? ?? //JAVA [??]
? ?? Jbang? ??? JDK ??? ???? ???? ???? ?? JDK? ???? ?? ?? ?????? ?????.
?? ?? ?? ????? Java 25 ? ?? ???? ??? ?????.
> jbang init helloworld.java
"Main" ???? ?? ????
????? ??? ???? ???? ?? ??? ?? ???? ?? ??????.
?????? Java?? ??? ?? ??? ? ???? ?? ????? ??? ????(Java 23??? ?? ?? ?? ?????).
? ??? ???? ??? ? ?? ?? ??? ?? Java ???? ? Jbang ????? ??? ? ????.
?? ????? ???? ??? ? ?????.
> jbang helloworld.java
Hello world
????? ?? ??? ???? ?????.
///usr/bin/env jbang "<pre class="brush:php;toolbar:false">> chmod +x helloworld.java
> ./helloworld.java
Hello world
" "$@" ; exit $?
import static java.lang.System.*;
public class helloworld {
public static void main(String... args) {
out.println("Hello world");
}
}
? ?? ? //JAVA 23 ? Jbang? Java 23 ??? ????? ?????.
? ?? ? ? ?? ?? //COMPILE_OPTIONS --enable-preview -source 23 ? //RUNTIME_OPTIONS --enable-preview? ?? ??? ? ???? ?? ?? ?? ??? ??????.
??? ????? 3?? ???? ????? ?? ?????. ????!
???
JBang? ? ???? ?? //DEPS atrefact-id:atrefact-name:version ??? ???? Gradle ??? ??? ??? ????? ???? ???? ?? ?????.
?? ??, jfiglet ?????? ????? ????? ?? ?? ???? ???: //DEPS com.github.lalyos:jfiglet:0.0.8.
> jbang init helloworld.java
????
JBang? ????? ???? ????? ???? ????? ???? ??? ? ????.
? ??? ???? ???? ????? ?? ???? ??? ????? ??? ????? ?? ?????.
????? ???? ?? ??? ??? ????? ?? ??? ???? ?? ????? ?????.
????? ??? ?????? ? ?? ?? ??? ???? jbang-catalog.json??? JSON ?????.
??? ???? ??? ??? ???? ?????? ????? ??? ? ??? ???? ? ????? ???? ?????.
????? ?? ?? ??? ? ??? ??? ?? ?? ?? ?? ?? ???? ???? ??? ? ????.
Jbang? ?? ?? ?? ??? ???? ??? ?? ????? ?? ????? ?? ??????.
JBang? ?? ??? ??? ?????? ?? ????? ????(?? JBang ??):
- ?? ????, ./jbang-catalog.json
- ./.jbang/jbang-catalog.json??
- ?? ???? ../jbang-catalog.json
- ??? .jbang ?????? ../.jbang/jbang-catalog.json
- ??? 3??? 4??? ?? ???? ???? ???? ????? ?????
- ??? ??? $HOME/.jbang/jbang-catalog.json? ???????.
JBang? GitHub, GitLab, Bitbucket ?? ?? ?? ?? ?? ????? ???? ????? ????.
?? ?????? GitHub? ?? ???????.
?? ????? ????? ???? ?? ??? jbang-catalog.json? ???? ???.
?? ?? ????? account/repository_name?? ?????.
??? ??? jbang-catalog?? ???? ??? ? ????.
?? ?? ? GitHub ??? ??? yostane?? jbang-catalog.json??? ??? ??? ????? ??? cours-java?? ???? ?? ?? yostane/cours-java? ?? ????? ??? ? ????. ?? jbang-catalog?? ???? jbang-catalog.json? ??? yostane/jbang-catalog ?? ??? yostane?? ??? ? ????.
> jbang helloworld.java
Hello world
?? ???? ????? ??? ???? ???? ??? ?????.
??
JBang? ??? ???? ?????? ????? ??? ? ????.
?? ??? ?? ?? ? ?? ??? ?? jbang alias@account/repository [args] ? jbang alias [args]???.
??? ?? ??? ???? ???? ??? ?? ???? ??? ? ????.
> jbang init helloworld.java
DevoxxMA 2024 ???? ??? ???????.
> jbang helloworld.java
Hello world
?? ??? ???? ??? ??? ??? ? ????.
- jbang palcli@yostane/cours-java ??
- jbang palqrest@yostane/cours-java
- jbang hellojfx@yostane/cours-java
JBang GitHub ?? ??? ??? ??? ???? ??? ????? ?????.
? ? ??? ??? ?????.
-
jbang httpd@jbangdev? ?? ???? ?????.
-
jbang gavsearch@jbangdev [arg] search.maven.org?? [arg]? ?????.
???
? ????? ????? ??? ? ?? ?? ??? ????? ???
?? ?? ??? ???? ???? ??? ??? ??? ?????.
///usr/bin/env jbang "<pre class="brush:php;toolbar:false">> chmod +x helloworld.java
> ./helloworld.java
Hello world
" "$@" ; exit $?
import static java.lang.System.*;
public class helloworld {
public static void main(String... args) {
out.println("Hello world");
}
}
???? ???? JBang? file-refs ??? ?? ??? ???? ?????.
file-ref? {basename}? ???? ??? Jbang? ?? ?? ?? ???? ???? ????.
file-ref? .qute ???? ???? ?? JBang? Qute ??? ??? ?????
??? ?? ??? ? ?? ?? ???? ????.
- picocli? ???? CLI ????: jbang init -t cli hellocli.java
- Quarkus ?? ?? REST API: jbang init -t qrest helloqrest.java
?????? ???? ???? ???? ??? ?? ????.
?? ??, ? ??? JUnit ?? ??? ??? jbang init -t junit@jbangdev file_to_test.java? ?????.
??? ?? jbangdev/jbang-catalog ????? ???? ??? jbang-catalog.json? ?? ? ????.
/// usr/bin/env jbang "<pre class="brush:php;toolbar:false">///usr/bin/env jbang "<pre class="brush:php;toolbar:false">//JAVA 23+
//COMPILE_OPTIONS --enable-preview -source 23
//RUNTIME_OPTIONS --enable-preview
" "$@" ; exit $?
//JAVA 23+
//COMPILE_OPTIONS --enable-preview -source 23
//RUNTIME_OPTIONS --enable-preview
void main(String... args) {
System.out.println("Hello World");
}
" "$@" ; exit $?
//JAVA 25
//COMPILE_OPTIONS --enable-preview -source 25
//RUNTIME_OPTIONS --enable-preview
import java.util.concurrent.Callable;
import java.util.concurrent.StructuredTaskScope;
import static java.lang.System.*;
void main(String... args) {
out.println("Hello Java 25");
Callable task1 = () -> {
out.println("Task 1" + Thread.currentThread());
return "Task 1";
};
Callable task2 = () -> {
out.println("Task 2" + Thread.currentThread());
return 2;
};
try (
var scope = new StructuredTaskScope