0

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.

1

I have done this in the past, so I know it's possible. Unfortunately, I can't remember exactly how. I would try starting some other GUI program like gedit, to see if you get any more informative messages. I'm pretty sure the problem is the GUI environment is not not ready at the point you are starting your app, so Java barfs. You might also look to see if you are ignoring any Exceptions or error returns in your Java app, thus passing a null pointer to the point where the error message occurs. If so, printing that error or exception might prove illuminating.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.