This project provides a set of utilities for scripting in Java. It allows you to write Java scripts productively and efficiently.
Modules (static objects) with tons of default behavior are available for use. You can use them in your scripts without writing boilerplate code.
It is a good idea to read the article on Dev.to to get a better understanding of the project: https://dev.to/toliyansky/scripting-with-java-3i9k
curl -s https://raw.githubusercontent.com/AnatoliyKozlov/scripting-utils/master/install.sh | bash
- Java 22 or higher
- Install scripting-utils. Execute one-line command from the Installation section above
- Create a shebang file (without the .java extension)
- Write your Java code in the file (as in example below)
#!/usr/bin/env java --source 22 --enable-preview --class-path /Users/toliyansky/scripting-utils
import static scripting.Utils.*;
void main() {
println("Hello, World!");
var response = http.get("https://httpbin.org/get");
log.info(response.body());
}
- Apply command
chmod +x your-file-name
to make it executable - Run the file from the command line. For example:
./your-file-name