Class Init1

  extended by ch.claudio.pen.Init1

public class Init1
extends java.lang.Object

Init replacement in Java

As I intend to run just Paper on my tablet computer, I wanted to have a very reduced Linux environment. Thus I thought to replace standard init, and execute Java right from Linux. To do so, the boot loader needs to execute the kernel with an init=/ argument. This wil execute the shell script / that should contain:

      export DISPLAY=:0
      while ! java -jar init.jar; do echo "Java crashed"; done
      kill -TERM -1
      sleep 1
      kill -KILL -1
      sleep 1
      umount -a
      halt -n -f -p 

The DISPLAY variable is only set here, because I do not know how to set it from within of this class. It can be left out in environments, where an X server is never started. The init.jar is executed which contains all classes and has this class defined as main class. If it returns with an error exit code it is restarted, otherwise the computer is shut down.

If reboot from here (through native library): Linux has a (2)reboot system call which accepts an argument: RB_POWER_OFF will halt and RB_AUTOBOOT will reboot. This call might return before the kernel shut down, thus after this call a wait needs to be placed and init must not be exited, because termination of process 1 would make the kernel panic

$Id: 114 2006-08-31 12:20:03Z claudio $
Claudio Nieder

Copyright (C) 2006 Claudio Nieder <>, CH-8610 Uster

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Constructor Summary
Method Summary
static void main(java.lang.String[] args)
          Print license.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Init1()
Method Detail


public static void main(java.lang.String[] args)
Print license. Init Linux then open the paper.

args - ignored