I want to open a new terminal window, which will run a certain command upon opening. It preferably needs to be a real native window, and I don't mind writing different code for linux/osx/windows.
I'm assuming an emulated terminal would work, as long as it supports everything a real terminal would do and isn't just printing lines of output from a command.
Opening a Terminal Window We can open the terminal window with ⌥F12 on macOS, or Alt+F12 on Windows and Linux. The terminal supports all the same commands that the operating system supports.
getRuntime(). exec("c:/elevate Rundll32.exe Powrprof. dll,SetSuspendState ");
I've used this on Ubuntu(X11 Desktop) 10.04 ~ 14.04, and other Debian distro's. Works fine; although, you may consider using Java's ProcessBuilder.
// GNU/Linux -- example Runtime.getRuntime().exec("/usr/bin/x-terminal-emulator --disable-factory -e cat README.txt"); // --disable-factory Do not register with the activation nameserver, do not re-use an active terminal // -e Execute the argument to this option inside the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With