4
# whichjava - determine properties of the given Java runtime
6
# Copyright (c) 2001 Ben Burton <benb@acm.org>
7
# Written for Debian GNU/Linux
10
# See man page for further details.
13
echo "$1" > /dev/stderr
17
echoerr "Usage: $0 <runtime> [ <action> ] [ <variable> ... ]"
19
echoerr "Runtime: path to a Java runtime command (eg. /usr/bin/java)"
20
echoerr "Actions: --eval, --print, --value (default)"
21
echoerr "Variables: bootstrap, jvm"
23
echoerr "See the man page for further details."
29
if [ -z "$action" ]; then
32
echoerr "More than one action has been specified!"
39
if [ -z "$variables" ]; then
42
variables="$variables $1"
47
echoerr "The core $1 classes could not be found."
49
echoerr "Set the environment variable \$BOOTSTRAP_CLASSES to a"
50
echoerr "colon-separated list of jars or directories containing"
51
echoerr "the core $1 classes (such as $2)"
52
echoerr "and try again."
57
# Pull the runtime command from the command line.
65
if ! which "$JAVA" 2>&1 > /dev/null; then
66
echoerr "The command \"$JAVA\" cannot be found."
71
# Find which action and variables were specified on the command line.
77
addvariable BOOTSTRAP_CLASSES
92
echoerr "Unknown command-line argument: $param"
98
# Use default if nothing was specified.
99
if [ -z "$variables" ]; then
100
variables="JVM BOOTSTRAP_CLASSES"
102
if [ -z "$action" ]; then
106
# Determine whose JVM we are using.
107
if [ -z "$JVM" ]; then
109
version=`"$JAVA" -version 2>&1` || true
111
# Search for a string not included in $JAVA so we don't accidentally
112
# catch output such as "kaffe: Command not found" and the like.
122
*Open\ Runtime\ Platform* )
125
java\ version\ \"1.1.8\" )
135
# Determine the bootstrap classes.
136
if [ -z "$BOOTSTRAP_CLASSES" ]; then
139
if [ -e /usr/share/java/libgcj.jar ]; then
140
BOOTSTRAP_CLASSES=/usr/share/java/libgcj.jar
142
classesnotfound "GNU Java" /usr/share/java/libgcj.jar
146
if [ -e /usr/lib/kaffe/lib/rt.jar ]; then
147
kaffejars=`ls /usr/lib/kaffe/lib/*.jar`
148
BOOTSTRAP_CLASSES=`echo $kaffejars | tr ' ' ':'`
149
elif [ -e /usr/share/kaffe/Klasses.jar ]; then
150
kaffejars=`ls /usr/share/kaffe/*.jar`
151
BOOTSTRAP_CLASSES=`echo $kaffejars | tr ' ' ':'`
153
classesnotfound "Kaffe" /usr/share/kaffe/Klasses.jar
157
if [ -e /usr/share/orp/classpath/java/lang/Object.class ]; then
158
BOOTSTRAP_CLASSES=/usr/share/orp/classpath
160
classesnotfound "ORP" /usr/share/orp/classpath
164
if [ -e /usr/lib/j2se/1.3/jre/lib/rt.jar ]; then
165
jrejars=`ls /usr/lib/j2se/1.3/jre/lib/*.jar`
166
BOOTSTRAP_CLASSES=`echo $jrejars | tr ' ' ':'`
167
elif [ -e /usr/lib/j2re1.3/lib/rt.jar ]; then
168
jrejars=`ls /usr/lib/j2re1.3/lib/*.jar`
169
BOOTSTRAP_CLASSES=`echo $jrejars | tr ' ' ':'`
171
classesnotfound "Blackdown Java" /usr/lib/j2se/1.3/jre/lib/rt.jar
175
if [ -e /usr/lib/jdk1.1/lib/classes.zip ]; then
176
BOOTSTRAP_CLASSES=/usr/lib/jdk1.1/lib/classes.zip
178
classesnotfound "Sun Java" /usr/lib/jdk1.1/lib/classes.zip
182
# No idea which JVM we're using.
188
# Output according to the requested action.
190
for v in $variables; do
193
command="echo \"$v=\\\"\$$v\\\" ;\""
196
command="echo $v: \$$v"