Search code examples
javaubuntusystemdesktop

How Can I Use a Java Application Instead of Desktop?


I want to make a Java Application that will start automatically when I start the computer and will run instead of the desktop, so the desktop-terminal etc will be unreachable for users. The users must use nothing but the application and when they close the application, the computer also must be turned off automatically. How can I do such a thing for a simple Java Application (jar)?


Solution

  • Shortly, for ubuntu you have to:

    • Remove desktop environment, just look around for some guides, it depends by which desktop you have (GNOME, XFCE, KDE, etc). https://askubuntu.com/a/147870

    • Add a script in /etc/rc.d and link it in rcS.d https://unix.stackexchange.com/a/83752.
      The script have to run your application, wait for end and shutdown, an example could be:

      #!/bin/bash
      
      nohup java -jar MyApp.jar &
      wait
      /sbin/shutdown -r now
      

    Try this in a virtual machine that you can reach in SSH or in some other ways, after you removed desktop environment, you cannot open a terminal.