简体   繁体   English

无头设备上的JavaFX

[英]JavaFX on headless device

I have built a javafx program and one part of it is a "server" which I can make print to a console but right now it prints to a text area in the javafx app. 我已经构建了一个Javafx程序,其中一部分是“服务器”,可以将其打印到控制台,但是现在它可以打印到javafx应用程序中的文本区域。 I changed the printstream to do this. 我改变了打印流来做到这一点。

One thing I tried was changing the main() method to to check if GraphicsEnvironment.isHandless() was true and if it was I'd run the headless server instead of the javafx app which has a client and server option. 我尝试做的一件事是更改main()方法以检查GraphicsEnvironment.isHandless()是否为真,如果是,我将运行无头服务器,而不是运行具有客户端和服务器选项的javafx应用程序。

However that gave me an exception saying graphics couldn't be initialised sew 但是那给了我一个例外,说无法初始化图形sew

Any ideas on how I can successfully run a JavaFX app on a VPS or Raspberry pi for example? 例如,关于如何在VPS或Raspberry pi上成功运行JavaFX应用程序的任何想法?

Thanks 谢谢

Ok so the best way to do this was modify my Main class to check a headless argument being passed through when running the jar. 好的,这样做的最好方法是修改Main类,以检查运行jar时传递的无头参数。

Then if it was I'd run a headless version of a class I made and if it wasn't then I'd run the JavaFX application. 然后,如果我运行的是我制作的类的无头版本,如果不是,那么我将运行JavaFX应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM