UpdateAlternatives
Version vom 21. April 2016, 12:51 Uhr von Hamatoma (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Kategorie:DesktopApplikation == Example == <pre>BASE=/opt/jdk1.8 alternatives --install /usr/bin/java java $BASE/bin/java $PRIO \ --slave /usr/bin/keytool…“)
Example[Bearbeiten]
BASE=/opt/jdk1.8 alternatives --install /usr/bin/java java $BASE/bin/java $PRIO \ --slave /usr/bin/keytool keytool $BASE/bin/keytool \ --slave /usr/bin/rmiregistry rmiregistry $BASE/bin/rmiregistry \ --slave /usr/bin/javac javac $BASE/bin/javac \ --slave /usr/bin/jar jar $BASE/bin/jar \ --slave /usr/bin/idlj idlj $BASE/bin/idlj \ --slave /usr/bin/rmic rmic $BASE/bin/rmic
Change environment[Bearbeiten]
update-alternatives -config java
Script for java[Bearbeiten]
FN=/usr/local/bin/InstJavaAlternative
cat <<'EOS' >$FN #! /bin/bash BASE=$1 PRIO=$2 function Usage(){ echo "usage: InstJavaAlternative <base_path> <prio>" echo "example: InstJavaAlternative /opt/jdk1.6 120" echo "+++ $1" exit 1 } ID=$(id -u) test $ID = 0 || Usage "be root!"; test -z "$BASE" && Usage "no base_path" test -d "$BASE" || Usage "not a directory: $BASE" test -x "$BASE/bin/java" || Usage "not a java installation: missing $BASE\bin\java" test -z "$PRIO" && Usage "missing <prio>" alternatives --install /usr/bin/java java $BASE/bin/java $PRIO \ --slave /usr/bin/keytool keytool $BASE/bin/keytool \ --slave /usr/bin/rmiregistry rmiregistry $BASE/bin/rmiregistry \ --slave /usr/bin/javac javac $BASE/bin/javac \ --slave /usr/bin/jar jar $BASE/bin/jar \ --slave /usr/bin/idlj idlj $BASE/bin/idlj \ --slave /usr/bin/rmic rmic $BASE/bin/rmic EOS chmod +x $FN