home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / j2sdk / files / linux / j2sdklin.bin / jdk1.3.1 / bin / .java_wrapper next >
Encoding:
Text File  |  2001-06-06  |  3.2 KB  |  125 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # @(#)java_wrapper_linux.sh    1.12 01/03/12
  5. #
  6. # Copyright 1994-2001 by Sun Microsystems, Inc.,
  7. # 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  8. # All rights reserved.
  9. #
  10. # This software is the confidential and proprietary information
  11. # of Sun Microsystems, Inc. ("Confidential Information").  You
  12. # shall not disclose such Confidential Information and shall use
  13. # it only in accordance with the terms of the license agreement
  14. # you entered into with Sun.
  15. #
  16.  
  17. PRG=$0
  18. SVPATH="$PATH"
  19. PATH=/bin:/usr/bin
  20.  
  21. progname=`basename $0`
  22. case "`uname -m`" in
  23.     i[3-6]86  | ia32 | ia64)
  24.         proc=i386
  25.         ;;
  26.     sparc*)
  27.         proc=sparc
  28.         ;;
  29.     *)
  30.         proc="`uname -m`"
  31.         ;;
  32. esac
  33.  
  34. # Resolve symlinks. See 4152645.
  35. while [ -L "$PRG" ]; do
  36.     ls=`ls -ld "$PRG"`
  37.     link=`expr "$ls" : '.*-> \(.*\)$'`
  38.     if expr "$link" : '/' > /dev/null; then
  39.     PRG="$link"
  40.     else
  41.     PRG="`dirname $PRG`/$link"
  42.     fi
  43. done
  44.  
  45. APPHOME=`dirname "$PRG"`/.. 
  46. JREHOME=$APPHOME/jre
  47.  
  48. # Where is JRE?
  49. unset jre
  50. if [ -f "${JREHOME}/lib/${proc}/libjava.so" ]; then
  51.     jre="${JREHOME}"
  52. fi
  53. if [ -f "${APPHOME}/lib/${proc}/libjava.so" ]; then
  54.     jre="${APPHOME}"
  55. fi
  56. if [ "x${jre}" = "x" ]; then
  57.     echo "Error: can't find libjava.so."
  58.     exit 1
  59. fi
  60.  
  61. # Get the canonicalized absolute pathnames
  62. jre="`$jre/bin/realpath $jre`"
  63. APPHOME="`${jre}/bin/realpath $APPHOME`"
  64. JREHOME="`${jre}/bin/realpath $JREHOME`"
  65. export APPHOME JREHOME
  66.  
  67. # Select vm type
  68. ttype=native_threads
  69. if grep "^$1\$" ${jre}/lib/jvm.cfg > /dev/null; then
  70.     # User specified some VM type known to jvm.cfg.
  71.     vmtype=`echo $1 | cut -c 2-`
  72. else
  73.     # User didn't specify a VM type, see if default is classic.
  74.     default=`grep -v '^#' "${jre}/lib/jvm.cfg" | head -1`
  75.     vmtype=`echo ${default} | cut -c 2-`
  76. fi
  77.  
  78. if [ "${vmtype}" = "classic" ]; then
  79.     ttype=green_threads
  80.     LD_BIND_NOW=yes
  81.     export LD_BIND_NOW
  82.     _JVM_THREADS_TYPE=green_threads
  83.     export _JVM_THREADS_TYPE
  84. fi              
  85.  
  86.  
  87. # If jre is in a jre subdir, include parent dir libraries in lib path.  This
  88. # needs to be cleaned up because -Xrun libraries are the ones that need it.
  89. if [ "${jre}" = "$JREHOME" ]; then
  90.    JAVA_LIBRARY_PATH=":${jre}/../lib/${proc}"
  91. fi
  92. # Set LD_LIBRARY_PATH for libjvm.so (necessitated by ld.so bugid 4176579)
  93. JAVA_LIBRARY_PATH="${jre}/lib/${proc}/${vmtype}$JAVA_LIBRARY_PATH"
  94.  
  95. # Set LD_LIBRARY_PATH to find libawt.so etc.
  96. JAVA_LIBRARY_PATH="${jre}/lib/${proc}:${jre}/lib/${proc}/${ttype}/:${JAVA_LIBRARY_PATH}"
  97.  
  98. LD_LIBRARY_PATH="${JAVA_LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
  99. export LD_LIBRARY_PATH
  100.  
  101. # bug #4344135 workaround
  102. # A thread currently waiting on a I/O operation will not wake up if one
  103. # of the files involved is actually closed (last close - the file is
  104. # no longer accessible but the thread is still waiting in the kernel).
  105. # The library libpreemptive_close.so is dynamically linked to the JVM 
  106. # iff the J2SE_PREEMPTCLOSE environment variable is set to 1
  107. #
  108. if [ "$J2SE_PREEMPTCLOSE" = 1 ]; then
  109.    LD_PRELOAD=${LD_PRELOAD}:libpreemptive_close.so
  110.    export LD_PRELOAD
  111. fi
  112.  
  113. prog="$APPHOME/bin/${proc}/${ttype}/${progname}"
  114.  
  115. # Run.
  116. if [ -x "$prog" ]
  117. then
  118.      # Calling: exec $DEBUG_PROG "$prog" "$@"
  119.      PATH="$SVPATH"
  120.      exec $DEBUG_PROG "$prog" "$@" 
  121. else
  122.     echo >&2 "$progname was not found in ${prog}"
  123.     exit 1
  124. fi
  125.