我正在使用jdeb爲基於debian的發行版生成我的.deb安裝程序。該應用程序已安裝,沒有錯誤,但是當我嘗試運行service myapp start
失敗與下面的異常(應用程序繼續運行,但從來沒有被顯示在FX場景):JavaFX - 導致:java.lang.UnsupportedOperationException:無法打開DISPLAY?
2016-12-30 11:19:51,468 [main] INFO o.s.c.s.DefaultLifecycleProcessor - Starting beans in phase 0
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
Caused by: java.lang.UnsupportedOperationException: Unable to open DISPLAY
at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:68)
at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
at com.sun.glass.ui.Application.run(Application.java:146)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:695)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
同時,如果我只需運行sudo /etc/init.d/myapp start
它運行沒有錯誤和我的第一個FX場景顯示。
貝婁是jdeb我的Maven配置:
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>1.5</version>
<executions>
<execution>
<id>appassembler</id>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<deb>${project.build.directory}/${project.build.finalName}.deb</deb>
<snapshotExpand>false</snapshotExpand>
<!-- expand "SNAPSHOT" to what is in the "USER" env variable -->
<snapshotEnv>USER</snapshotEnv>
<verbose>true</verbose>
<controlDir>${basedir}/src/deb/control</controlDir>
<dataSet>
<data>
<src>${project.build.directory}/${project.build.finalName}-uber.jar</src>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>/opt/stone/${project.build.finalName}</prefix>
<filemode>755</filemode>
<user>root</user>
<group>root</group>
</mapper>
</data>
<data>
<src>src/deb/upstart/${project.build.finalName}.conf</src>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>/opt/stone/${project.build.finalName}</prefix>
<filemode>755</filemode>
<user>root</user>
<group>root</group>
</mapper>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
這是我的安裝後腳本:
#!/bin/bash
echo Creating symblink...
sudo ln -s /opt/stone/acs/acs-uber.jar /etc/init.d/acs
echo Creating service...
sudo update-rc.d acs start 98 5 .
echo Starting service...
sudo service acs restart
服務在後臺運行,不能交互。他們不能有用戶界面。 – VGR
那麼有沒有辦法像守護進程一樣提高這樣的應用程序? – romerorsp
順便說一句感謝您的評論 – romerorsp