source: josm/trunk/linux/tested/usr/bin/josm@ 8777

Last change on this file since 8777 was 8777, checked in by Don-vip, 9 years ago

Basic Java 9 support: make code compile, and Linux scripts detect it

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/bin/sh
2# Simple wrapper script used to start JOSM in Debian
3set -e
4
5# First, the alternative (if known to work) or users preference as defined by $JAVA_HOME. Next, use OpenJDK or Oracle's proprietary JDK.
6# Override to a specific one using $JAVACMD
7ALTERNATIVE_JDK="`readlink -n -f /etc/alternatives/java`"
8
9# Let's get the current architecture -- needed for multiarchified Java
10ARCH="`dpkg --print-architecture 2> /dev/null || true`"
11
12# If OpenJDK is only available headless, do not try it
13if dpkg --get-selections 'openjdk-*-jre' | grep install$ > /dev/null ; then
14 JAVA9_CMDS="/usr/lib/jvm/java-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java /usr/lib/jvm/java-9-oracle/bin/java"
15 JAVA8_CMDS="/usr/lib/jvm/java-8-openjdk/bin/java /usr/lib/jvm/java-8-openjdk-$ARCH/bin/java /usr/lib/jvm/java-8-oracle/bin/java"
16 JAVA7_CMDS="$JAVA_HOME/bin/java /usr/lib/jvm/java-7-openjdk/bin/java /usr/lib/jvm/java-7-openjdk-$ARCH/bin/java /usr/lib/jvm/java-7-oracle/bin/java"
17else
18 JAVA9_CMDS="/usr/lib/jvm/java-9-oracle/bin/java"
19 JAVA8_CMDS="/usr/lib/jvm/java-8-oracle/bin/java"
20 JAVA7_CMDS="$JAVA_HOME/bin/java /usr/lib/jvm/java-7-oracle/bin/java /usr/bin/java"
21fi
22
23JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
24
25for jcmd in $JAVA8_CMDS; do
26 if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
27 JAVACMD="$jcmd"
28 fi
29done
30
31for jcmd in $JAVA8_CMDS; do
32 if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
33 JAVACMD="$jcmd"
34 fi
35done
36
37for jcmd in $JAVA7_CMDS; do
38 if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
39 JAVACMD="$jcmd"
40 fi
41done
42
43for jcmd in $JAVA7_CMDS; do
44 if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
45 JAVACMD="$jcmd"
46 fi
47done
48
49for jcmd in $JAVA9_CMDS; do
50 if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
51 JAVACMD="$jcmd"
52 fi
53done
54
55for jcmd in $JAVA9_CMDS; do
56 if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
57 JAVACMD="$jcmd"
58 fi
59done
60
61if [ "$JAVACMD" ]; then
62 echo "Using $JAVACMD to execute josm." || true
63 set +e
64 while true; do
65 $JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
66 if [ "z$?" != "z9" ]; then
67 break
68 fi
69 echo ">> restarting josm..."
70 done
71else
72 echo "No valid JVM found to run JOSM." || true
73 exit 1
74fi
Note: See TracBrowser for help on using the repository browser.