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

Last change on this file since 15167 was 15167, checked in by Don-vip, 4 months ago

see #16047, fix #17794 - add java.sql module when loading JOSM with Java 11+

  • Property svn:executable set to *
File size: 2.4 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.
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        JAVA_CMDS="$JAVA_HOME/bin/java"
15        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-11-openjdk/bin/java /usr/lib/jvm/java-11-openjdk-$ARCH/bin/java"
16        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-openjdk/bin/java /usr/lib/jvm/java-8-openjdk-$ARCH/bin/java"
17        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-12-openjdk/bin/java /usr/lib/jvm/java-12-openjdk-$ARCH/bin/java"
18        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-10-openjdk/bin/java /usr/lib/jvm/java-10-openjdk-$ARCH/bin/java"
19        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java"
20        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-13-openjdk/bin/java /usr/lib/jvm/java-13-openjdk-$ARCH/bin/java"
21else
22        JAVA_CMDS="$JAVA_HOME/bin/java /usr/bin/java"
23fi
24
25if [ -f /etc/default/josm ]; then
26    . /etc/default/josm
27fi
28
29JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
30
31if [ -z "${JAVACMD}" ]; then
32    for jcmd in $JAVA_CMDS; do
33        if [ "z$ALTERNATIVE_JDK" = "z`readlink -n -f $jcmd`" ] && [ -z "${JAVACMD}" ]; then
34            JAVACMD="$jcmd"
35            break
36        fi
37    done
38fi
39
40if [ -z "${JAVACMD}" ]; then
41    for jcmd in $JAVA_CMDS; do
42        if [ -x "$jcmd" -a -z "${JAVACMD}" ]; then
43            JAVACMD="$jcmd"
44            break
45        fi
46    done
47fi
48
49if [ "$JAVACMD" ]; then
50    echo "Using $JAVACMD to execute josm." || true
51    if [ "`expr match \"${JAVACMD}\" 'java-9'`" != "0" ] || [ "`expr match \"${JAVACMD}\" 'java-10'`" != "0" ]; then
52        JAVA_OPTS="--add-modules java.activation,java.se.ee $JAVA_OPTS"
53    elif [ "`expr match \"${JAVACMD}\" 'java-1'`" != "0" ]; then
54        JAVA_OPTS="--add-modules java.scripting,java.sql $JAVA_OPTS"
55    fi
56    set +e
57    while true; do
58        $JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
59        if [ "z$?" != "z9" ]; then
60            break
61        fi
62        echo ">> restarting josm..."
63    done
64else
65    echo "No valid JVM found to run JOSM." || true
66    exit 1
67fi
Note: See TracBrowser for help on using the repository browser.