* lib/getcwd.c (__getcwd): Remove redundant comparison of buf to NULL.
[gnulib.git] / build-aux / javaexec.sh.in
1 #!/bin/sh
2 # Execute a Java program.
3
4 # Copyright (C) 2001, 2006 Free Software Foundation, Inc.
5 # Written by Bruno Haible <haible@clisp.cons.org>, 2001.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21 # This uses the same choices as javaexec.c, but instead of relying on the
22 # environment settings at run time, it uses the environment variables
23 # present at configuration time.
24 #
25 # This is a separate shell script, because it must be able to unset JAVA_HOME
26 # in some cases, which a simple shell command cannot do.
27 #
28 # The extra CLASSPATH must have been set prior to calling this script.
29
30 CONF_JAVA='@CONF_JAVA@'
31 CONF_CLASSPATH='@CLASSPATH@'
32 if test -n "@HAVE_JAVA_ENVVAR@"; then
33   # Combine given CLASSPATH and configured CLASSPATH.
34   if test -n "$CLASSPATH"; then
35     CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
36   else
37     CLASSPATH="$CONF_CLASSPATH"
38   fi
39   export CLASSPATH
40   test -z "$JAVA_VERBOSE" || echo "$CONF_JAVA $@"
41   exec $CONF_JAVA "$@"
42 else
43   unset JAVA_HOME
44   export CLASSPATH
45   if test -n "@HAVE_GIJ@"; then
46     # In this case, $CONF_JAVA is "gij".
47     test -z "$JAVA_VERBOSE" || echo "$CONF_JAVA $@"
48     exec $CONF_JAVA "$@"
49   else
50     if test -n "@HAVE_JAVA@"; then
51       # In this case, $CONF_JAVA is "java".
52       test -z "$JAVA_VERBOSE" || echo "$CONF_JAVA $@"
53       exec $CONF_JAVA "$@"
54     else
55       if test -n "@HAVE_JRE@"; then
56         # In this case, $CONF_JAVA is "jre".
57         test -z "$JAVA_VERBOSE" || echo "$CONF_JAVA $@"
58         exec $CONF_JAVA "$@"
59       else
60         if test -n "@HAVE_JVIEW@"; then
61           # In this case, $CONF_JAVA is "jview".
62           test -z "$JAVA_VERBOSE" || echo "$CONF_JAVA $@"
63           exec $CONF_JAVA "$@"
64         else
65           echo 'Java virtual machine not found, try installing gij or set $JAVA, then reconfigure' 1>&2
66           exit 1
67         fi
68       fi
69     fi
70   fi
71 fi