LINUX.ORG.RU

Как прописать JVM в PATH в RH8?


0

0

Добрый день! Собственно,сабж... Просто есть программулина, требующая java virtual mashine.JVM под Линукс Рэд Хат 8 скачал,поставил, а что дальше делать - сообразить не могу :-( Как быть? Заранее спасибо!

anonymous

Re: Как прописать JVM в PATH в RH8?

Я кинул в /etc/profile.d скрипт, который прописывает необходимые мне переменные окружения.
---------------------
myEnv.sh

# my personal enviroment initialization script (sh)
if [ -z "$JAVA_HOME" ] ; then
JAVA_HOME="/usr/local/tools/jdk"
fi
export JAVA_HOME

if [ -z "$ANT_HOME" ] ; then
ANT_HOME="/usr/local/tools/ant"
fi
export ANT_HOME

if [ -z "$TOMCAT_HOME" ] ; then
TOMCAT_HOME="/usr/local/tools/tomcat"
fi
export TOMCAT_HOME
export PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin

PartyZan ★★★ ()

Re: Как прописать JVM в PATH в RH8?

NO_J2SDK=1
J2RE=/usr/java/j2re1.4.2_01
J2SDK=/usr/java/j2sdk1.4.2_01

if [ -d "$J2SDK" ] ; then
    JAVA_HOME=$J2SDK
    JDK_HOME=$JAVA_HOME
    JAVAC=$JAVA_HOME/bin/javac
    CLASSPATH=$J2SDK/jre/lib/rt.jar:.
    PATH="$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH"
    MANPATH="$JAVA_HOME/man:$MANPATH"
    export JAVA_HOME JDK_HOME JAVAC CLASSPATH PATH MANPATH
    NO_J2SDK=0
fi

if [ "$NO_J2SDK" = 1 ] ; then
if [ -d "$J2RE" ] ; then
    JAVA_HOME=$J2RE
    CLASSPATH=$J2RE/lib/rt.jar:.
    PATH="$JAVA_HOME/bin:$PATH"
    MANPATH="$JAVA_HOME/man:$MANPATH"
    export JAVA_HOME CLASSPATH PATH MANPATH
fi
fi


В /etc/profile.d под именем j2se.sh

jackill ★★★★★ ()

Re: Как прописать JVM в PATH в RH8?

/etc/init.d/java
-----------------------
#!/bin/sh
#
# java  Allow users to run Java(tm) applications by just clicking on them
#       (or typing ./file.class)
#
# chkconfig: - 37 97 11
# description: Allow users to run Java(tm) applications by just clicking \
#              on them (or typing ./file.class)

. /etc/rc.d/init.d/functions
prog="java"

RETVAL=0

start() {
        echo -n $"Registering binary handler for Java applications"
        (
        echo ':Java:M::\xca\xfe\xba\xbe::/usr/local/bin/javawrapper:' >/proc/sys
/fs/binfmt_misc/register && :
        echo ':ExecutableJar:E::jar::/usr/local/bin/jarwrapper:' >/proc/sys/fs/b
infmt_misc/register && success
        ) || failure
        echo;
}

stop() {
        echo -n $"Unregistering binary handler for Java applications"
        (
        echo "-1" >/proc/sys/fs/binfmt_misc/Java && :
        echo "-1" >/proc/sys/fs/binfmt_misc/ExecutableJar && success
        ) || failure
        echo;
}

reload() {
        stop
        start
}

java_status() {
        if [ -e /proc/sys/fs/binfmt_misc/Java ]; then
                echo $"Java bytecode format handlers are registered."
                return 0
        else
                echo $"Java bytecode format handlers are not registered."
                return 3
        fi
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status)
                java_status
                RETVAL=$?
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -e /proc/sys/fs/binfmt_misc/Java ]; then
                        stop
                        start
                fi
                ;;
        *)
                echo $"Usage: $prog {start|stop|status|restart|condrestart}"
                exit 1
esac
exit $RETVAL

/usr/local/bin/javawrapper
-----------------
# /usr/local/bin/javawrapper - the wrapper for binfmt_misc/java

if [ -z "$1" ]; then
        exec 1>&2
        echo Usage: $0 class-file
        exit 1
fi

CLASS=$1
FQCLASS=`/usr/local/bin/javaclassname $1`
FQCLASSN=`echo $FQCLASS | sed -e 's/^.*\.\([^.]*\)$/\1/'`
FQCLASSP=`echo $FQCLASS | sed -e 's-\.-/-g' -e 's-^[^/]*$--' -e 's-/[^/]*$--'`

# for example:
# CLASS=Test.class
# FQCLASS=foo.bar.Test
# FQCLASSN=Test
# FQCLASSP=foo/bar

unset CLASSBASE

declare -i LINKLEVEL=0

while :; do
        if [ "`basename $CLASS .class`" == "$FQCLASSN" ]; then
                # See if this directory works straight off
                cd -L `dirname $CLASS`
                CLASSDIR=$PWD
                cd $OLDPWD
                if echo $CLASSDIR | grep -q "$FQCLASSP$"; then
                        CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."`
                        break;
                fi
                # Try dereferencing the directory name
                cd -P `dirname $CLASS`
                CLASSDIR=$PWD
                cd $OLDPWD
                if echo $CLASSDIR | grep -q "$FQCLASSP$"; then
                        CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."`
                        break;
                fi
                # If no other possible filename exists
                if [ ! -L $CLASS ]; then
                        exec 1>&2
                        echo $0:
                        echo "  $CLASS should be in a" \
                             "directory tree called $FQCLASSP"
                        exit 1
                fi
        fi
        if [ ! -L $CLASS ]; then break; fi
        # Go down one more level of symbolic links
        let LINKLEVEL+=1
        if [ $LINKLEVEL -gt 5 ]; then
                exec 1>&2
                echo $0:
                echo "  Too many symbolic links encountered"
                exit 1
        fi
        CLASS=`ls --color=no -l $CLASS | sed -e 's/^.* \([^ ]*\)$/\1/'`
done

if [ -z "$CLASSBASE" ]; then
        if [ -z "$FQCLASSP" ]; then
                GOODNAME=$FQCLASSN.class
        else
                GOODNAME=$FQCLASSP/$FQCLASSN.class
        fi
        exec 1>&2
        echo $0:
        echo "  $FQCLASS should be in a file called $GOODNAME"
        exit 1
fi

if ! echo $CLASSPATH | grep -q "^\(.*:\)*$CLASSBASE\(:.*\)*"; then
        # class is not in CLASSPATH, so prepend dir of class to CLASSPATH
        if [ -z "${CLASSPATH}" ] ; then
                export CLASSPATH=$CLASSBASE
        else
                export CLASSPATH=$CLASSBASE:$CLASSPATH
        fi
fi

shift
/usr/java/j2sdk/jre/bin/java $FQCLASS "$@"

/usr/local/bin/jarwrapper
-----------------------
#!/bin/bash
# /usr/local/java/bin/jarwrapper - the wrapper for binfmt_misc/jar

java -jar $1

/etc/profile.d/java.sh 
----------------------
[ `echo $PATH | grep /usr/java/j2sdk/bin` ] || \
export PATH=$PATH:/usr/java/j2sdk/bin
[ `echo $PATH | grep /usr/java/j2sdk/jre/bin` ] || \
export PATH=$PATH:/usr/java/j2sdk/jre/bin
[ `echo $JAVA_HOME ` ] || \
export JAVA_HOME=/usr/java/j2sdk/jre
export JDBCHOME=$JAVA_HOME/lib/i386
export CLASSPATH=.:$JAVA_HOME/lib

hooj ★★ ()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.