I am building a machine using the Raspberry Pi (Raspbian). I am developing a JAVA GUI application and I want it to run at startup.

Basically the machine's only purpose is to run that application, without the desktop environment. How can I do that?

Also, in case it matters, I still need network capabilities, and I will also be plugging-in a printer.

  • I think you can disable the GUI from automatically starting up by allowing it and clearing the option to boot into the GUI option (sorry can't remember the exact wording used) on the Raspberry Pi configuration option on the "Start" menu. To restart the normal LXDE GUI i.e. the Desktop Environment later, run the startlxde-pi script and reselect that option. However, it may be that you will need the XServer running in order to display the Java VM output - I am not too familiar with that system - in which case I think you will want to investigate what the startx and xinit script do.
    – SlySven
    Commented Dec 28, 2015 at 1:06
  • 1
    I think you can also define that when the machine boots it can auto login at the console. This will load the user's .profile script which can start your app. You didn't mention which UI you are using, however if you are using JavaFX then you do not want to run X as JavaFX expects to own the full screen.
    – Kolban
    Commented Dec 28, 2015 at 2:45
  • @Dan are you developing using javafx or swing ?
    – Ahmed
    Commented Apr 30, 2016 at 3:46

1 Answer 1


Here is an example of what you could do:

The Pi needs to be configured to launch the desired app at startup. Lets assume that our app is called javafile.jar.

In order to do this:

  1. Create a file named /etc/xdg/autostart/startup.desktop
  2. Put the following contents into it

    [Desktop Entry] Type=Application
    Exec=/user/home/jre/java -jar javafile.jar
  3. Restart.

Another way to do this is to have the exec line call a script in your home folder that launches your java app instead of calling the app directly. You can create a file called javalauncher in your home directory with the following contents:

    #! /usr/bin/bash
    #my java launcher file

    /user/home/jre/java -jar javafile.jar

Then update your exec entry in the startup.desktop file to call the javalauncher command file like so:

    [Desktop Entry] Type=Application 

Remember to chmod +x on your javalauncher file.

  • What about a python GUI app? Commented Apr 28, 2016 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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