I have a Java Swing GUI that needs to be run on boot. Tried adding a shell script (which starts the program) in config/lxsession/LXDE-pi/autostart : @sh script.sh
script.sh:
export DISPLAY=:0.0
sudo java -classpath .:classes:/opt/pi4j/lib/'*' PARCX_Terminal/MainForm
The program runs fine when script.sh is executed outside the .config. But when I execute it in the LXDE-pi , I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException.
Also tried different options for export DISPLAY but got the following error:
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':1.0' as the value of the DISPLAY variable.
I am new to Raspberry Pi and would request the experts to guide me in the right direction to run the GUI program on boot.