在不显示的情况下在Ubuntu服务器上部署JavaFX [英] Deploy JavaFX on Ubuntu server without display

查看:65
本文介绍了在不显示的情况下在Ubuntu服务器上部署JavaFX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Netbeans的Mac OS X(10.9.1)上使用jdk1.7.0_51开发JavaFX应用程序.我可以毫无问题地运行它,并且在完成构建后,我还可以从dist/文件夹启动jar.

I'm developing a JavaFX application using jdk1.7.0_51 on Mac OS X (10.9.1) in Netbeans. I can run it without a problem and after a clean build I can also launch the jar from the dist/ folder.

现在,我要将其部署在64位Ubuntu 13.04服务器上.我在执行此操作时遇到了很多问题,但最终将服务器设置为具有正确的JRE,字体和库.运行jar会导致错误比我的代码更严重(转到提到MACOS的本机库的UnsatisfiedLinks),所以我认为最好将应用程序打包在Ubuntu上.我最终安装了NetBeans以创建一个新的(本机)JavaFX项目,并使用sftp从我的计算机上载了src/和lib/文件夹.通过NetBeans中的重建项目运行代码可以很好地运行,尽管在运行过程中我在控制台中收到了警告:

Now I want to deploy this on a 64 bit Ubuntu 13.04 server. I've had a lot of issues doing this but have finally set up the server to have the correct JRE, fonts and libraries. Running the jar resulted in errors going way deeper than my code (going to UnsatisfiedLinks to native libraries where MACOS was mentioned) so I figured it would be best to package my app on Ubuntu itself. I ended up installing NetBeans to make a new (native) JavaFX project and uploaded the src/ and lib/ folders from my machine using sftp. Running the code through the reconstructed project in NetBeans works fine, though I get a warning in the console during run:

libGL error: failed to load driver: swrast
libGL error: Try again with LIBGL_DEBUG=verbose for more details.
Prism-ES2 Error : GL_VERSION (major.minor) = 1.4

无论如何,该应用程序都可以运行.干净生成后,我可以类似地从dist/文件夹中运行jar.相同的警告出现在终端中,但随后应用程序启动.

Regardless, the application DOES run. After a clean build, I can similarly run the jar from the dist/ folder. The same warning appears in the terminal but then the application launches.

但是,如果我在没有-X标志的情况下ssh到服务器并尝试运行该应用程序,则会得到以下信息:

However, if I ssh to the server without the -X flag and try to run the application, I get the following:

Failed in XOpenDisplay
(java:29341): Gtk-WARNING **: cannot open display: 

但是,我的应用程序没有UI.它只是将JavaFX用于WebEngine(这是必需的,不能更改).我想知道是否有人(如果知道,怎么知道)是否可以在没有显示的情况下启动JavaFX jar(仅作为守护程序在服务器上运行).

However, my application does not have a UI. It simply uses JavaFX for the WebEngine (this is required and can not be changed). I was wondering if anyone knows if (and if so, how) it's possible to launch my JavaFX jar without a display (to just run as a daemon on the server).

亲切的问候, 沃克(Warkst)

Kind regards, Warkst

我已经尝试过此处描述的一些操作:

I've tried some things described here: Java Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable

You need to specify the -Djava.awt.headless=true parameter at startup time.

(假设我使用命令java -Djava.awt.headless=true -jar MyApp.jar正确执行了此操作),则没有任何结果(发生相同的错误).

(Assuming I'm doing it right with the command java -Djava.awt.headless=true -jar MyApp.jar), this yielded no results (the same errors occur).

export DISPLAY=:0

仍然没有结果,尽管错误显然已更改为现在的内容:

Still no result, though the error obviously changed slightly to now read:

(java:30765): Gtk-WARNING **: cannot open display: :0

然后最后我也尝试了以下方法:

Then finally I also tried the following:

unset DISPLAY

这导致了原始错误(显然未设置DISPLAY).

This resulted in the original error (where obviously DISPLAY was not set).

推荐答案

我认为JavaFX 2.x不支持以无头模式运行.我不知道有什么解决方法.

I don't think JavaFX 2.x supports running in a headless mode. I don't know of any workaround.

有关更多信息,请参阅JavaFX问题跟踪器功能请求: RT-34241在以下环境中使用WebEngine无头系统,目前计划用于Java 9.

For further info see the JavaFX issue tracker feature request: RT-34241 Use of WebEngine in a headless system, currently scheduled for implementation for Java 9.

这篇关于在不显示的情况下在Ubuntu服务器上部署JavaFX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆