2016-06-14 51 views
1

我試圖在ubuntu 16.04中執行java swing程序,它與默認用戶正常工作,但是當我更改用戶時,它不工作並顯示以下錯誤。未在ubuntu中運行的Java Swing程序

No protocol specified 
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable. 
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) 
    at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65) 
    at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:264) 
    at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103) 
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82) 
    at java.awt.Window.initGC(Window.java:475) 
    at java.awt.Window.init(Window.java:495) 
    at java.awt.Window.<init>(Window.java:537) 
    at java.awt.Frame.<init>(Frame.java:420) 
    at java.awt.Frame.<init>(Frame.java:385) 
    at javax.swing.JFrame.<init>(JFrame.java:189) 
    at ImageButton.<init>(ImageButton.java:6) 
    at ImageButton.main(ImageButton.java:23) 

任何人都可以幫助我這個請。

+0

你看到http://stackoverflow.com/questions/10165761/java-cant-connect-to-x11-window-server-using-localhost10 -O-作爲最值的叔? – Apostolos

+0

是的,我看到了,但那並沒有解決我的問題。 – karthi

+0

你是否也看到了另一個建議設置無頭標誌的答案? – Fildor

回答

0

如果java awt進程的用戶不是你(登錄到桌面的人),它可能不會傳遞xauth。 嘗試通過共享您的.Xauthority給該用戶:

export XAUTHORITY=/home/<you>/.Xauthority