I am excited to announce the first major release of jPowerShell2! This version is a complete overhaul of the original library, focused on performance, modern Java standards, and cross-platform flexibility.
馃専 What's New?
- Java 21 Support: We now utilize Virtual Threads (Project Loom) for I/O handling. This makes sessions extremely lightweight and allows for high-concurrency without thread exhaustion.
- Zero-Delay I/O: Optimized the CommandProcessor to eliminate artificial wait times (waitPause). The library now reacts instantly as soon as PowerShell provides output.
馃寪 PowerShell Core (pwsh) Integration
- Full support for PowerShell Core (7+).
- New
openSession(boolean useCore) method to easily targetpwshon Windows, Linux, and macOS. - Improved UTF-8 handling for cross-platform consistency.
馃攧 Asynchronous API
Added executeCommandAsync(String command), returning a CompletableFuture. Run your PowerShell tasks in the background without blocking your main application logic.
馃洜 Improvements & Refactoring
- Efficient Script Execution: Used
transferTofor faster script loading from JAR resources. - Regex-free Trimming: Improved string processing performance by replacing heavy Regex with manual whitespace trimming.
鈿狅笍 Important Note on Requirements
This release requires Java 21 or higher to take advantage of Virtual Threads and modern I/O features.
馃捇 Quick Start
try (PowerShell ps = PowerShell.openSession(true)) { // true = Use PowerShell Core
var response = ps.executeCommand("Get-Date");
System.out.println(response.getCommandOutput());
}