I am probably not completely sure what you are specifically looking to do. But to print the entire screen, I just use the “Print Scr” key on my keyboard. That captures the whole screen and automatically saves it to the Pictures folder in your home directory.
I am not a Java expert but I would guess that telling AWT to operate in headless mode is designed to make it work without touching/needing a real display, in which case it may not be surprising that it can’t take a screenshot of the real display.
@wjt thank you for the reply! I still can’t take a screenshot You are right. Enabling headless mode is wrong. But in this case nothing is happens. Just flashing cursor in the terminal…
gnome-screenshot has non-disabling animation. And that’s a slightly different story to call terminal commands in Java.
I searched the app center for other screenshot apps. I found ksnip which seems to work OK and did not flash the screen:
wjt@camille:~$ flatpak run org.ksnip.ksnip --fullscreen --save
Warning: QSocketNotifier: Can only be used with threads started with QThread
Info: Image Saved: Saved to /sysroot/home/wjt/ksnip_20210914-194547.png
Ignore the canberra error. It’s thrown because the module is not available in the Runtime used by the application in question - in a Flatpak environment, everything need to be available either directly in the flatpak or in the runtime.
You can’t install it seperatly like in Ubuntu per Design.
The canberra library is sometimes used by GTK applications to provide playback of event sounds as a fallback method, so it shouldn’t be a issue if it’s not there.