Home > Blockchain >  Exception in thread "main" java.awt.HeadlessException: No X11 DISPLAY variable was set, wh
Exception in thread "main" java.awt.HeadlessException: No X11 DISPLAY variable was set, wh

Time:11-10

My java program should open the default browser and open a link. When I local start the java program on my ubuntu server it works just fine, but when I start the program per ssh it gives me this error:

Exception in thread "main" java.awt.HeadlessException: 
No X11 DISPLAY variable was set,
but this program performed an operation which requires it.
        at java.desktop/java.awt.Desktop.getDesktop(Desktop.java:302)
        at Server.openURL(Server.java:69)
        at Server.main(Server.java:58)

Maybe when starting per ssh it uses a headless version of java? Thanks!


CodePudding user response:

I know now what the problem is. SSH makes a new session without a gui, even if you connected with Remote Desktop. And you cant open a browser in a session with no gui.

The solution I have is, that I connect via remote desktop to the server and open my program in the terminal. My program has now a session with gui and the browser opens.

  • Related