2016-12-30 441 views
4

我正在使用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 
+3

服务在后台运行,不能交互。他们不能有用户界面。 – VGR

+0

那么有没有办法像守护进程一样提高这样的应用程序? – romerorsp

+0

顺便说一句感谢您的评论 – romerorsp

回答

0

报价从其他地方使用JavaFX为我工作的根在Ubuntu的答案.. 。 也许这可以帮助别人。我和你有同样的问题,但对于普通用户。假设我想使用用户帐户foo启动firefox。我登录的酒吧:该命令中的问题(即没有协议规定的失败,相同的错误

[巴@本地〜] $ sudo的-u富-H火狐

可悲的是&无法打开显示)

我的解决方案是简单地将用户foo添加到X服务器的授权访问列表中。

xhost的SI:localuser:富

,就是这样,当时我能够使用sudo和用户foo推出火狐(和其他X应用程序)。