source: josm/trunk/native/linux/latest/usr/bin/josm-latest@ 17530

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

see #19724, see #20522 - java 16/17 support in Linux launch scripts

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