Ken, you are totally right. I also think that this is one on the aspects of JAVA that need some work. For example the fact that the Java command is a script, implies that it is not possible in UNIX to define a scripting language in Java. I.e., define a version of perl in Java (lets call it jperl) and being able to say:
#!/bin/jperl my script here... And the reason for this is that jperl is a script invoking some other script and so on. Has someone thought on defining a task for generating standarized script files for java programs in different platforms? jinstall and some other installation tools have this ability. It wold be nice if we could provide a way to generate such files and that know about how to do it in different platforms. That could simplify and standarized some of this issues alot. The task could by default generate the version for the particular execution environment one is at the moment, or a list of platforms if specified. Is jinstall open source? Jose Alberto > -----Original Message----- > From: Ken Wood [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 08, 2000 10:48 AM > To: [EMAIL PROTECTED] > Subject: Re: [suggestion] re: Bootstrapping Ant > > > I think this boils down to: > > 1. java apps are platform independent > > 2. invoking java apps is platform dependent > > Just look at the installation of the JDK itself from, > say, IBM on AIX, Sun on Solaris, or HP on HPUX, and > you'll find that when you type "java -jar ant.jar" > you are invoking a shell script of some kind. > > So, while it may be 'ugly' in some fashion, I > don't know of a way around it. I've looked > at commercial apps and they all address this > issue one way or another. Sometimes they > wrap their java apps in bat/shell scripts. > Sometimes they wrap them in python scripts > or perl scripts. At some point the OS > independent app has to be invoked in an OS > dependent way... > > Example: on solaris 2.6 "java" is actually > this shell script, which has to deal with > issues like native threads vs green threads, > etc... > > #!/bin/ksh -p > # > # @(#)java_wrapper.sh 1.52 99/01/13 > # > # Copyright 1994-1998 by Sun Microsystems, Inc., > # 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. > # All rights reserved. > # > > #=================================================================== > # THIS SCRIPT AND JAVA WILL NOT RUN UNDER SUNOS4.X, AKA SOLARIS 1.X. > #=================================================================== > > PRG=`whence $0` >/dev/null 2>&1 > progname=`/usr/bin/basename $0` > proc=`/usr/bin/uname -p` > APPHOME=`/usr/bin/dirname "$PRG"`/.. > > # Resolve symlinks. See 4152645. > while [ -h "$PRG" ]; do > ls=`/usr/bin/ls -ld "$PRG"` > link=`/usr/bin/expr "$ls" : '^.*-> \(.*\)$'` > if /usr/bin/expr "$link" : '^/' > /dev/null; then > prg="$link" > else > prg="`/usr/bin/dirname $PRG`/$link" > fi > PRG=`whence "$prg"` > /dev/null 2>&1 > APPHOME=`/usr/bin/dirname "$PRG"`/.. > done > > JREHOME=$APPHOME/jre > > # Where is JRE? > unset jre > if [ -f "${JREHOME}/lib/${proc}/libjava.so" ]; then > jre="${JREHOME}" > fi > if [ -f "${APPHOME}/lib/${proc}/libjava.so" ]; then > jre="${APPHOME}" > fi > if [ "x${jre}" = "x" ]; then > echo "Error: can't find libjava.so." > exit 1 > fi > > # Select vm type (if classic vm, also select thread type). > unset vmtype > unset ttype > DEFAULT_THREADS_FLAG=green > > if [ "x$1" = "x-hotspot" ]; then > vmtype=hotspot > ttype=native_threads > shift 1 > else > if [ "x$1" = "x-classic" ]; then > vmtype=classic > ttype=${DEFAULT_THREADS_FLAG}_threads > shift 1 > else > if [ "x$1" = "x-green" ]; then > vmtype=classic > ttype=green_threads > shift 1 > else > if [ "x$1" = "x-native" ]; then > vmtype=classic > ttype=native_threads > shift 1 > else > if [ -d ${jre}/lib/${proc}/hotspot ]; then > vmtype=hotspot > ttype=native_threads > else > vmtype=classic > if [[ ${THREADS_FLAG:-${DEFAULT_THREADS_FLAG}} = > native ]] > then > ttype=native_threads > else > ttype=green_threads > fi > fi > fi > fi > fi > fi > > # Special handling for classic VM. > if [ "${vmtype}" = "classic" ]; then > # fix for bug 4032715 > if [[ ${ttype} = green_threads ]] ; then > LD_BIND_NOW=yes > export LD_BIND_NOW > fi > # For internal use by classic VM. > _JVM_THREADS_TYPE="${ttype}" > export _JVM_THREADS_TYPE > fi > > # Set LD_LIBRARY_PATH for hotspot VM. > LD_LIBRARY_PATH="${jre}/lib/${proc}/${ttype}:${jre}/lib/${proc > }/${vmtype}:${jre}/lib/${proc}:$LD_LIBRARY_PATH" > export LD_LIBRARY_PATH > > # prepend XFILESEARCHPATH with awt Motif default locale > resource files. > XFILESEARCHPATH="${jre}/lib/locale/%L/%T/%N%S:$XFILESEARCHPATH" > export XFILESEARCHPATH > > prog="$APPHOME/bin/${proc}/${ttype}/${progname}" > > # Run. > if [ -x "$prog" ] > then > exec $DEBUG_PROG "$prog" "$@" > else > echo >&2 "$progname was not found in ${prog}" > exit 1 > fi >
