JavaFx in silent mode

Is it possible to run JavaFx in headless mode (in Java 7)? It is used to create images on the server, but asks for X-Server. Is there something like java.awt.headless in JavaFx? (I can not use xvfb)

+6
source share
4 answers

Here's how I solved this problem for a genartion server image in a Linux Ubuntu environment with a berth application server. It uses xvfb, but only as a β€œlibrary” - without any additional special actions on the server:

apt-get install xvfb // then on application server start: export DISPLAY=":99" start-stop-daemon --start --background --user jetty --exec "/usr/bin/sudo" -- -u jetty /usr/bin/Xvfb :99 -screen 0 1024x768x24 

You can see the details of my server side image creation solution in this SO question .

+2
source

The answer to this question by Shreyas Dave did not help me anymore. Although I don’t know why, here is what I did:

 public static void main(String[] args) { // to avoid // [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode. System.setProperty("javafx.macosx.embedded", "true"); java.awt.Toolkit.getDefaultToolkit(); // end launch(args); } 

It was also mentioned here: JavaFX screencapture OSX headless exception

+1
source

This is the problem I encountered while capturing images on Mac OS.

I solved this problem using

 static { System.setProperty("java.awt.headless", "false"); } 

See help: Error of headless environment in java.awt.Robot class with MAC OS

0
source

If you have the source code for the JavaFX application, you can also try using TestFX to run the application in headless mode, to manage it and take screenshots. To run the TestFX application in silent mode, you must run it with the following JVM options (to enable Monocle ):

 -Dtestfx.robot=glass -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw 

In addition, you may need to install Monocle first. See Mute Testing with JavaFx and TestFx for more details .

-1
source

Source: https://habr.com/ru/post/959024/


All Articles