I need to run a Java JAR Swing GUI executable in a Raspbian Wheezy Debian distribution inside an ARM device during boot time.I am following this as reference with myapp,myapp-start.sh and myapp-stop.sh, and this with possible solutions (and others more quite similar). But here is not reference to the DISPLAY variable.Ive checked a lot of alternatives, with Tried and not applicable Options:/usr/bin/java -jar -Djava.awt.headless=true $myapp.jarunset DISPLAY (inside myapp-start.sh, above the java -jar sentence)Errors: java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it.Tried Options (inside myapp-start.sh, above the java -jar sentence):export DISPLAY=:0export DISPLAY=:0.0export DISPLAY=localhost:0.0Errors:Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable...Client is not authorized to connect to ServerException in thread stack...Untried Optionsssh - X localhost: How should i do an ssh to the X11 server? Where should i execute that under an init.d process?. Is that the standard solution for running a Java program with GUI?.USER=root inside myapp-start.sh: The init.d stops, and request password. So smart, the process don`t start.  Should any of the options above to be included in another place than the myapp-start.sh code? Where?Should not be simpler to run a single piece of code at startup?.Any other option, will be appreciated.EDIT 2015-04-12New OptionsIn the following options, i am adding a code inside this location /etc/xdg/lxsession/LXDE-pi/autostart for execution after the default user pi logs and X11 starts (see jlliagre suggestion):usr/bin/java -jar /home/pi/Embedded/bin/PowerBar.jar (no ampersand)export DISPLAY=:0.0usr/bin/java -jar /home/pi/Embedded/bin/PowerBar.jar (no ampersand)/bin/bash /home/pi/Embedded/bin/powerbarstart.sh (no ampersand)All them start the application in the background, that is, the background music is played, and the graphics are available only through a VNC at :0 (using TightVNC). As side effect, the screensaver activates, and the application freezes, each 60 seconds approx. Please note this same location is also used to disable the screensaver.Is there a missing option, or symbol, I am not including?.SolutionThe device was configured as :1.0 instead of :0.0. Changing this on the myapp-start.sh solved the issue.
How to setup DISPLAY to run a Java JAR Swing Executable from Init.d
debian;java;display;init.d
If your application is not interactive, you might launch a virtual X11 server and set the DISPLAY variable for your application to use it.Possible X11 servers that can be used that way are:XvfbXdummyXvncThe latter allows you to connect later to see and interact with the screen with a VNC client (vncviewer).If you Raspberry pi (or similar) is configured to autologin the pi user under a graphical environment, you can start your application as the pi user and use the :0 display. Beware that you have to make sure X11 has completed its startup before doing it.Edit: It looks like your configuration is launching a Xvnc server first as the pi user then is launching the frame buffer main X server as the root user. In that case, as you figured out, your application has to be started as root and using :1 as its display.Alternatively, if what you really want is not to start your application once at boot time but whenever a user (typically pi) logs in under a graphic environment, add it to the rc file applicable to this graphic environment. For example /etc/xdg/lxsession/LXDE-pi/autostart.