Hi everyone, I'm new to rust. I have a requirement: use rust to start the Java jar package and run it as a child process. When rust exits, the jar also exits, and the jar runs in the background. How to avoid a black window under Windows.
You can use spawn to launch the process in the background, but waiting for it to exit is fiddly, easier to use status in a background thread. You can use [
creation_flags on windows'
CommandExt]CommandExt in std::os::windows::process - Rust on windows to avoid creating a console window with
java.exe (the exact flag to use depends on how you want to deal with already having a console window) or you can simply use javaw.exe instead. In either case, you can use
#[cfg(windows)] to conditionally compile based on when you're building for Windows, and you'll probably want to add #![windows_subsystem = "windows"] too.