source: josm/trunk/native/linux/tested/usr/bin/josm

Last change on this file was 18297, checked in by Don-vip, 7 months ago

fix #21059 - add exports in Linux start scripts as for other native launchers

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#!/bin/bash
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
12JAVA_CMDS="$JAVA_HOME/bin/java"
13
14# If OpenJDK is only available headless, do not try it
15if dpkg --get-selections "openjdk-*-jre" | grep install$ > /dev/null \
16|| dpkg --get-selections "openjdk-*-jre:$ARCH" | grep install$ > /dev/null ; then
17        # LTS versions in decreased order
18        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-17-openjdk/bin/java /usr/lib/jvm/java-17-openjdk-$ARCH/bin/java"
19        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-11-openjdk/bin/java /usr/lib/jvm/java-11-openjdk-$ARCH/bin/java"
20        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-8-openjdk/bin/java /usr/lib/jvm/java-8-openjdk-$ARCH/bin/java"
21        # Released versions in decreased order
22        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-16-openjdk/bin/java /usr/lib/jvm/java-16-openjdk-$ARCH/bin/java"
23        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-15-openjdk/bin/java /usr/lib/jvm/java-15-openjdk-$ARCH/bin/java"
24        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-14-openjdk/bin/java /usr/lib/jvm/java-14-openjdk-$ARCH/bin/java"
25        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-13-openjdk/bin/java /usr/lib/jvm/java-13-openjdk-$ARCH/bin/java"
26        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-12-openjdk/bin/java /usr/lib/jvm/java-12-openjdk-$ARCH/bin/java"
27        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-10-openjdk/bin/java /usr/lib/jvm/java-10-openjdk-$ARCH/bin/java"
28        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-9-openjdk/bin/java /usr/lib/jvm/java-9-openjdk-$ARCH/bin/java"
29        # Development version(s)
30        JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/java-18-openjdk/bin/java /usr/lib/jvm/java-18-openjdk-$ARCH/bin/java"
31fi
32# Undetermined version
33JAVA_CMDS="${JAVA_CMDS} /usr/lib/jvm/default-java/bin/java /usr/bin/java"
34
35if [ -f /etc/default/josm ]; then
36    . /etc/default/josm
37fi
38
39JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
40
41if [ -z "${JAVACMD}" ]; then
42    for jcmd in $JAVA_CMDS; do
43        if [ "z$ALTERNATIVE_JDK" = "z$(readlink -n -f "$jcmd")" ] && [ -z "${JAVACMD}" ]; then
44            JAVACMD="$jcmd"
45            break
46        fi
47    done
48fi
49
50if [ -z "${JAVACMD}" ]; then
51    for jcmd in $JAVA_CMDS; do
52        if [ -x "$jcmd" ] && [ -z "${JAVACMD}" ]; then
53            JAVACMD="$jcmd"
54            break
55        fi
56    done
57fi
58
59if [ "$JAVACMD" ]; then
60    echo "Using $JAVACMD to execute josm." || true
61    if [[ "${JAVACMD}" =~ 'java-9' ]] || [[ "${JAVACMD}" =~ 'java-10' ]]; then
62        JAVA_OPTS="--add-modules java.activation,java.se.ee $JAVA_OPTS"
63    elif [[ "${JAVACMD}" =~ 'java-1' ]]; then
64        JAVA_OPTS="--module-path /usr/share/openjfx/lib --add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web $JAVA_OPTS"
65        JAVA_OPTS="$JAVA_OPTS --add-exports=java.base/sun.security.action=ALL-UNNAMED"
66        JAVA_OPTS="$JAVA_OPTS --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED"
67        JAVA_OPTS="$JAVA_OPTS --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED"
68    fi
69    set +e
70    while true; do
71        $JAVACMD $JAVA_OPTS -jar /usr/share/josm/josm.jar "$@"
72        if [ "z$?" != "z9" ]; then
73            break
74        fi
75        echo ">> restarting josm..."
76    done
77else
78    echo "No valid JVM found to run JOSM." || true
79    exit 1
80fi
Note: See TracBrowser for help on using the repository browser.