create bsd12 branch

This commit is contained in:
ziggi
2019-12-26 07:26:06 +00:00
commit 5cfdab6bfe
14432 changed files with 2272620 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
#
# $Id$
#
PORTNAME= javavmwrapper
PORTVERSION= 2.5
CATEGORIES= java
MASTER_SITES= # none
DISTFILES= # none
MAINTAINER= glewis@FreeBSD.org
COMMENT= Wrapper script for various Java Virtual Machines
NO_BUILD= yes
NO_WRKSUBDIR= yes
PKGINSTALL= ${WRKDIR}/pkg-install
SRC= ${.CURDIR}/files/src
SCRIPTS= classpath javavmwrapper
# This is normally defined by bsd.java.mk when USE_JAVA is defined, but
# we can't do that here since it would result in a circular dependency
JAVALIBDIR= ${LOCALBASE}/share/java/classes
do-configure:
.for _script in ${SCRIPTS}
${SED} -e 's|%%PREFIX%%|${PREFIX}|;' \
-e 's|%%JAVALIBDIR%%|${JAVALIBDIR}|;' \
${SRC}/${_script}.sh >${WRKSRC}/${_script}.sh
.endfor
${SED} -e 's|%%LOCALBASE%%|${LOCALBASE}|;' \
${FILESDIR}/pkg-install.in > ${PKGINSTALL}
.for _man in checkvms.1 javavm.1 manvm.1 registervm.1 javavm_opts.conf.5 javavms.5
${SED} -e 's|%%PREFIX%%|${PREFIX}|;' \
-e 's|%%LOCALBASE%%|${LOCALBASE}|;' \
-e 's|%%PORTSDIR%%|${PORTSDIR}|;' \
${SRC}/${_man} > ${WRKSRC}/${_man}
.endfor
PORTEXAMPLES= *
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/classpath.sh ${STAGEDIR}${PREFIX}/bin/classpath
${INSTALL_SCRIPT} ${WRKSRC}/javavmwrapper.sh ${STAGEDIR}${PREFIX}/bin/javavm
${LN} -sf javavm ${STAGEDIR}${PREFIX}/bin/checkvms
${LN} -sf javavm ${STAGEDIR}${PREFIX}/bin/manvm
${LN} -sf javavm ${STAGEDIR}${PREFIX}/bin/registervm
${LN} -sf javavm ${STAGEDIR}${PREFIX}/bin/unregistervm
${INSTALL_MAN} ${WRKSRC}/*.1 ${STAGEDIR}${MAN1PREFIX}/man/man1
${INSTALL_MAN} ${WRKSRC}/registervm.1 \
${STAGEDIR}${MAN1PREFIX}/man/man1/unregistervm.1
${INSTALL_MAN} ${WRKSRC}/*.5 ${STAGEDIR}${MAN5PREFIX}/man/man5
${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
${INSTALL_DATA} ${FILESDIR}/javavm_opts.conf.dist \
${STAGEDIR}${EXAMPLESDIR}/javavm_opts.conf.sample
.include <bsd.port.mk>
#EOF

View File

@@ -0,0 +1,50 @@
#
# $FreeBSD: head/java/javavmwrapper/files/javavm_opts.conf.dist 340872 2014-01-24 00:14:07Z mat $
#
# javavm_opts.conf.dist
#
# This file is sourced by javavm to determine the options to pass to the
# Java command that its invoking.
#
# There are four different types of environment variables that are used
# to determine the options for a particular command.
#
# 1. JAVAVM_OPTS
#
# The contents of this variable are passed as options to all java
# commands invoked by javavm.
#
# 2. JAVAVM_OPTS_JAVA_HOME_DIR
#
# The contents of this variable are passed as options to all java
# commands invoked by javavm within the JAVA_HOME_DIR directory specified.
# The JAVA_HOME_DIR specified here is the directory portion of $JAVA_HOME
# with special characters replaced by an underscore. For example, the
# standard installation of the jdk15 port puts it in /usr/local/jdk1.5.0,
# so to affect all of its programmes you would set JAVAVM_OPTS_jdk1_5_0.
#
# 3. JAVAVM_OPTS_JAVAVM_PROG
#
# The contents of this variable are passed as options to all invocations
# of the specified java programme. For example, if you always wish to
# have -deprecation passed to javac, then you would set JAVAVM_OPTS_javac.
#
# 4. JAVAVM_OPTS_JAVA_HOME_JAVAVM_PROG
#
# The contents of this variable are passed as options to the invocation
# of the specified java programme within the specified JAVA_HOME
# directory. This allows the options to only affect a single programme.
# For example, to pass -Xlint to the javac in /usr/local/jdk1.5.0/bin
# you would set JAVAVM_OPTS_jdk1_5_0_javac.
#
# These variables "stack", in that if multiple variables are
# defined which apply to a particular command then all the variables
# contents will be passed to the command as options. For example,
# if you set JAVAVM_OPTS_jdk1_5_0 and JAVAVM_OPTS_javac, then the
# contents of both variables will be passed to an invocation of
# /usr/local/jdk1.5.0/bin/javac.
#
# Note that the order in which variables stack is an implementation
# detail and should not be relied upon.
#

View File

@@ -0,0 +1,25 @@
#!/bin/sh
#
# $FreeBSD: /tmp/pcvs/ports/java/javavmwrapper/files/pkg-install.in,v 1.3 2006-06-03 17:32:24 glewis Exp $
LOCALBASE=%%LOCALBASE%%
# This script runs during post-install
if [ "x${2}" != "xPOST-INSTALL" ]; then
exit 0
fi
# Ensure all JDKs and JREs are installed
_excl_dirs='bootstrap-openjdk'
_find_expr='-depth 2 -regex .*/bin/java'
for dir in ${_excl_dirs}; do
_find_expr="${_find_expr} ! -regex ${dir}/bin/java"
done
for jvm in `cd "${LOCALBASE}" && find *jdk* *jre* ${_find_expr} 2> /dev/null`; do
if [ -x "${LOCALBASE}/${jvm}" ]; then
"${PKG_PREFIX}"/bin/registervm "${LOCALBASE}/${jvm}" > /dev/null 2>&1
fi
done
# Ensure all VMs are configured correctly
"${PKG_PREFIX}"/bin/checkvms

View File

@@ -0,0 +1,56 @@
.\"
.\" Copyright (C) 2005 Greg Lewis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: head/java/javavmwrapper/src/checkvms.1 340872 2014-01-24 00:14:07Z mat $
.\"
.Dd February 24, 2005
.Os
.Dt CHECKVMS 1
.Sh NAME
.Nm checkvms
.Nd sanity check registered Java VMs
.Sh SYNOPSIS
.Nm checkvms
.Sh DESCRIPTION
Each registered Java VM is checked to ensure that it exists and that
all appropriate symbolic links for it have been created.
Non-existent Java VMs are unregistered and missing symbolic links are created.
The Java VMs are also sorted using a hard-coded ordering that will
sort them by version and affinity with
.Fx .
.Sh FILES
.Bl -tag -width indent
.It Pa %%PREFIX%%/etc/javavms
The location of the Java VM wrapper configuration file.
.El
.Sh SEE ALSO
.Xr javavm 1 ,
.Xr registervm 1 ,
.Xr unregistervm 1 ,
.Xr javavms 5
.Sh BUGS
The
.Nm
utility removes both blank lines and purely comment lines from
the Java VM wrapper configuration file.

View File

@@ -0,0 +1,11 @@
#!/bin/sh
#
# $FreeBSD: head/java/javavmwrapper/src/classpath.sh 340872 2014-01-24 00:14:07Z mat $
#
JAVALIBDIR=%%JAVALIBDIR%%
echo -n .
find -s ${JAVALIBDIR} -name '*.jar' | while read jar ; do
echo -n ":${jar}"
done

View File

@@ -0,0 +1,225 @@
.\"
.\" Copyright (C) 2005 Greg Lewis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: head/java/javavmwrapper/src/javavm.1 340872 2014-01-24 00:14:07Z mat $
.\"
.Dd February 24, 2005
.Os
.Dt JAVAVM 1
.Sh NAME
.Nm javavm
.Nd convenient wrapper for switching Java VMs
.Sh SYNOPSIS
.Nm
.Op Ar arguments ...
.Sh DESCRIPTION
The Java VM wrapper provides a convenient system for switching between
different Java VMs.
It also provides symbolic links in
.Pa %%LOCALBASE%%/bin
to allow the use of
the Java executables without having to add the specific Java VM executable
directories to the
.Ev PATH
environment variable.
.Pp
The
.Nm
utility itself is currently a synonym for
.Dq java .
However, this behaviour
is deprecated and is provided only for compatibility with the previous
version of
.Nm .
This functionality may be removed in a future version and should not be
relied upon.
.Pp
By default,
.Nm
will select the most
.Dq native
and up to date version of the Java VM when
a given symbolic link is used, invoking and passing the arguments to the
matching executable within the chosen Java VM.
The choice of Java VM may also be influenced by using environment variables
to constrain the version, vendor and operating system of the Java VM.
.Pp
This selection process is usually achieved through the use of
.Pa %%PORTSDIR%%/Mk/bsd.java.mk .
However, if this is not present then
.Nm
will use its own internal selection process which is
designed to behave almost identically.
.Sh ENVIRONMENT
.Bl -tag -width indent
.It Ev JAVA_HOME
The presence of this variable in the environment when executing
.Nm
will override all other considerations regarding the Java VM to be used
and the Java VM located at
.Pa ${JAVA_HOME}/bin/java
will be used.
.Pp
This variable is set by
.Nm
when executing the actual Java VM and will be available to it and all of
its child processes.
.It Ev JAVA_OS
A space delimited list of operating systems.
The selected Java VM must have been created for one of the operating systems
in the list.
.Pp
Currently allowed operating system values are
.Ql native
and
.Ql linux .
.It Ev JAVA_VENDOR
A space delimited list of Java VM vendors.
The selected Java VM must have been released by one of the vendors in the list.
.Pp
Currently allowed vendors are
.Ql bsdjava ,
.Ql freebsd ,
.Ql openjdk
and
.Ql sun .
.It Ev JAVA_VERSION
A space delimited list of versions of the Java VM that may be used.
By appending a
.Ql +
to a version, any Java VM with a version greater than or
equal to the given version will be used.
.Pp
Currently allowed versions are
.Ql 1.5 ,
.Ql 1.5+ ,
.Ql 1.6 ,
.Ql 1.6+ ,
.Ql 1.7
and
.Ql 1.7+ .
.It Ev JAVAVM_OPTS
The contents of this environment variable will be passed to the invoked
Java VM as options.
For more information on environment variables which can be used to set
options see
.Pa %%PREFIX%%/etc/javavm_opts.conf.dist .
.It Ev JAVAVM_FALLBACK_ONLY
If this variable is set then instead of selecting the Java VM based on
.Pa %%PORTSDIR%%/Mk/bsd.java.mk
only the internal selection process is used.
This may be useful to achieve consistent results for Java VM selection
across multiple hosts, where some have the ports collection installed
and others do not.
However, this option, when used with scripts installed by a port, may
result in Java VM selection inconsistent with that intended by the script
author.
.It Ev JAVAVM_DRYRUN
When this variable is set, no Java VM is invoked.
Instead, the Java VM wrapper prints out the following information:
.Bl -tag -width indent
.It Ev JAVA_HOME
The value of the
.Ev JAVA_HOME
environment variable which the Java VM wrapper would have set before
invoking the Java VM.
.It Ev JAVAVM_CONF
The Java VM wrapper configuration file being used.
.It Ev JAVAVM_OPTS_CONF
The Java VM wrapper option configuration file being used.
.It Ev JAVAVM_PROG
The Java VM that would have been invoked.
.It Ev JAVAVM_OPTS
The options that would have been passed to the invoked Java VM.
It is important to note that this variable may not be the same as the
.Ev JAVAVM_OPTS
environment variable due to processing of the Java VM wrapper option
configuration file.
.It Ev JAVAVM_COMMAND
The full command line that would have been used to invoke the Java VM.
.El
.El
.Sh FILES
.Bl -tag -width indent
.It Pa %%PREFIX%%/etc/javavms
The location of the Java VM wrapper configuration file.
.It Pa %%PREFIX%%/etc/javavm_opts.conf
The location of the Java VM wrapper option configuration file.
.It Pa %%PORTSDIR%%/Mk/bsd.java.mk
The file usually used, along with
.Nm make ,
to select the Java VM to be used.
.El
.Sh EXAMPLES
.Bl -tag -width indent
.It Pa %%LOCALBASE%%/bin/java
Execute the most up to date and
.Dq native
Java VM registered with
.Nm .
.It Ev JAVA_VERSION=1.5+ Pa %%LOCALBASE%%/bin/javac MyClass.java
Compile MyClass.java with a registered Java VM's javac that is at least
version 1.5.
.It Ev JAVA_OS=native Pa %%LOCALBASE%%/bin/java Fl jar Pa MyApp.jar
Execute MyApp with the most up to date native Java VM that is registered
with
.Nm .
This is necessary if MyApp uses JNI, for instance.
.It Ev JAVA_VERSION="1.5 1.7" Pa %%LOCALBASE%%/bin/java Fl jar Pa MyApp.jar
Execute MyApp with either a Java VM that is either version 1.5 or version 1.7.
.It Ev JAVAVM_DRYRUN=yes Pa %%LOCALBASE%%/bin/java
Don't invoke the Java VM, but print out information about what would have
been done.
This could be used in a script to determine the
.Ev JAVA_HOME
that the Java VM wrapper will use, for instance:
.Lp
.Ev JAVA_HOME=`env JAVAVM_DRYRUN=yes %%LOCALBASE%%/bin/java | grep '^JAVA_HOME' | cut -c11-`
.El
.Sh SEE ALSO
.Xr checkvms 1 ,
.Xr make 1 ,
.Xr manvm 1 ,
.Xr registervm 1 ,
.Xr unregistervm 1 ,
.Xr javavm_opts.conf 5 ,
.Xr javavms 5
.Sh BUGS
The internal selection procedure of
.Nm
is not fully identical to that used when
.Pa %%PORTSDIR%%/Mk/bsd.java.mk
is present.
In particular,
.Nm
does not respect environment variables such as
.Ev JAVA_PREFERRED_PORTS
which is used by
.Pa %%PORTSDIR%%/Mk/bsd.java.mk
and will not use the values of such variables if they are set up as
.Nm make
variables in
.Pa /etc/make.conf ,
for example.

View File

@@ -0,0 +1,98 @@
.\"
.\" Copyright (C) 2006 Greg Lewis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: head/java/javavmwrapper/src/javavm_opts.conf.5 340872 2014-01-24 00:14:07Z mat $
.\"
.Dd May 28, 2006
.Os
.Dt JAVAVM_OPTS.CONF 5
.Sh NAME
.Nm javavm_opts.conf
.Nd the Java VM wrapper options configuration file.
.Sh DESCRIPTION
The file
.Nm
contains variables which set options that should be passed to the
Java VM that is invoked by the Java VM wrapper.
.Pp
Which Java VM a variable provides options for is determined by the variable
name. The Java VM wrapper currently recognises the following patterns for
variable names:
.Bl -tag -width indent
.It Ev JAVAVM_OPTS
The options specified by this variable are passed to all Java VM
invocations. In practise, this variable should be reserved for use
on the command line and not set in
.Nm .
.It Ev JAVAVM_OPTS_JAVA_HOME_DIR
The contents of this variable are passed as options to all java
commands invoked by javavm within the
.Pa JAVA_HOME_DIR
directory specified.
The
.Pa JAVA_HOME_DIR
specified here is the directory portion of
.Ev JAVA_HOME
with special characters replaced by an underscore.
.It Ev JAVAVM_OPTS_JAVA_PROG
The contents of this variable are passed as options to all invocations
of the specified java programme.
.It Ev JAVAVM_OPTS_JAVA_HOME_DIR_JAVA_PROG
The contents of this variable are passed as options to the invocation
of the specified java programme within the specified JAVA_HOME
directory.
This allows the options to only affect a single programme.
.El
.Sh FILES
.Bl -tag -width indent
.It Pa %%PREFIX%%/etc/javavm_opts.conf
The location of the Java VM wrapper options configuration file.
.It Pa %%PREFIX%%/etc/javavm_opts.conf.dist
The location of the example Java VM wrapper options configuration file
distributed with the Java VM wrapper.
.El
.Sh EXAMPLES
.Bl -tag -width indent
.It Ev JAVAVM_OPTS_diablo_jdk1_5_0=-XX:+UseMembar
Run the Java VMs installed by the Diablo JDK in
.Pa %%PREFIX%%/diablo-jdk1.5.0
with the option
.Dq -XX:+UseMembar .
.It Ev JAVAVM_OPTS_javac=-deprecation
Run the
.Pa javac
programme with the option
.Dq -deprecation .
.It Ev JAVAVM_OPTS_diablo_jdk1_5_0_javac=-Xlint
Run the javac installed by the Diablo JDK with the option
.Dq -Xlint .
.El
.Pp
Due to stacking, if the above three variables were set, then the javac
installed by the Diablo JDK would run with the options
.Dq -XX:+UseMembar -deprecation -Xlint
(although not necessarily in that order).
.Sh SEE ALSO
.Xr javavm 1

View File

@@ -0,0 +1,61 @@
.\"
.\" Copyright (C) 2005 Greg Lewis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: head/java/javavmwrapper/src/javavms.5 340872 2014-01-24 00:14:07Z mat $
.\"
.Dd February 24, 2005
.Os
.Dt JAVAVMS 5
.Sh NAME
.Nm javavms
.Nd the Java VM wrapper configuration file.
.Sh DESCRIPTION
The
.Nm
file contains a list of the registered Java VMs which are available to be
used by
.Nm javavm .
Each Java VM is listed by specifying the location of the main
.Dq java
executable on a line.
.Pp
The
.Nm
file may also contains comments.
Comments must start with the
.Sq #
character, and can be both lines by
themselves or the trailing portion of a line containing a registered
Java VM.
.Sh FILES
.Bl -tag -width indent
.It Pa %%PREFIX%%/etc/javavms
The location of the Java VM wrapper configuration file.
.El
.Sh SEE ALSO
.Xr checkvms 1 ,
.Xr javavm 1 ,
.Xr registervm 1 ,
.Xr unregistervm 1

View File

@@ -0,0 +1,646 @@
#!/bin/sh
#
# javawrapper.sh
#
# Allow the installation of several Java Virtual Machines on the system.
# They can then be selected from based on environment variables and the
# configuration file.
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):
# Maxim Sobolev <sobomax@FreeBSD.org> wrote this file. As long as you retain
# this notice you can do whatever you want with this stuff. If we meet some
# day, and you think this stuff is worth it, you can buy me a beer in return.
#
# Maxim Sobolev
# ----------------------------------------------------------------------------
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):
# Greg Lewis <glewis@FreeBSD.org> substantially rewrote this file. As long
# as you retain this notice you can do whatever you want with this stuff. If
# we meet some day, and you think this stuff is worth it, you can buy me a
# beer in return.
#
# Greg Lewis
# ----------------------------------------------------------------------------
#
# $FreeBSD: head/java/javavmwrapper/src/javavmwrapper.sh 351127 2014-04-12 19:43:17Z glewis $
#
# MAINTAINER=java@FreeBSD.org
_JAVAVM_SAVE_PATH=${PATH}
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
_JAVAVM_PREFIX="%%PREFIX%%"
_JAVAVM_CONF="${_JAVAVM_PREFIX}/etc/javavms"
_JAVAVM_OPTS_CONF="${_JAVAVM_PREFIX}/etc/javavm_opts.conf"
_JAVAVM_PROG=`basename "${0}"`
_JAVAVM_MAKE=/usr/bin/make
#
# Try to run a Java command.
#
tryJavaCommand () {
# If this is a test run, spit out the configuration and exit
if [ -n "${JAVAVM_DRYRUN}" ]; then
echo "JAVA_HOME=${JAVA_HOME}"
echo "JAVAVM_CONF=${_JAVAVM_CONF}"
echo "JAVAVM_OPTS_CONF=${_JAVAVM_OPTS_CONF}"
echo "JAVAVM_PROG=${1}"
echo "JAVAVM_OPTS=${_JAVAVM_OPTS}"
echo "JAVAVM_COMMAND=${@}"
exit 0
fi
# Check for the command being executable and exec it if so.
if [ -x "${1}" ]; then
if [ -n "${_JAVAVM_SAVE_PATH}" ]; then
export PATH=${_JAVAVM_SAVE_PATH}
fi
exec "${@}"
fi
echo "${_JAVAVM_PROG}: warning: couldn't run specified Java command - \"${1}\"" 1>&2
}
#
# Set java command options, if applicable
# 1 - Name of the java programme to be executed.
# 2 - Base directory of JAVA_HOME for the java programme to be executed.
#
setJavaOptions () {
local OPTS_PROG=`echo ${1} | sed -e s/\\\\./_/g -e s/-/_/g`
local OPTS_JAVA_HOME=`echo ${2} | sed -e s/\\\\./_/g -e s/-/_/g`
local JAVA_HOME_PROG_OPTS="`eval echo \$\{JAVAVM_OPTS_${OPTS_JAVA_HOME}_${OPTS_PROG}\} 2>/dev/null`"
local JAVA_HOME_OPTS="`eval echo \$\{JAVAVM_OPTS_${OPTS_JAVA_HOME}\} 2>/dev/null`"
local PROG_OPTS="`eval echo \$\{JAVAVM_OPTS_${OPTS_PROG}\} 2>/dev/null`"
# Possible environment variables are stackable
if [ -n "${JAVA_HOME_PROG_OPTS}" ]; then
_JAVAVM_OPTS="${JAVA_HOME_PROG_OPTS} ${_JAVAVM_OPTS}"
fi
if [ -n "${JAVA_HOME_OPTS}" ]; then
_JAVAVM_OPTS="${JAVA_HOME_OPTS} ${_JAVAVM_OPTS}"
fi
if [ -n "${PROG_OPTS}" ]; then
_JAVAVM_OPTS="${PROG_OPTS} ${_JAVAVM_OPTS}"
fi
if [ -n "${JAVAVM_OPTS}" ]; then
_JAVAVM_OPTS="${JAVAVM_OPTS} ${_JAVAVM_OPTS}"
fi
}
#
# Create symbolic links for all of a Java VMs executables.
#
createJavaLinks () {
for exe in "${1}"/bin/* "${1}"/jre/bin/*; do
if [ -x "${exe}" -a \
! -d "${exe}" -a \
"`basename "${exe}"`" = "`basename "${exe}" .so`" -a \
! -e "${_JAVAVM_PREFIX}/bin/`basename "${exe}"`" -a \
-w "${_JAVAVM_PREFIX}/bin" ]; then
ln -s "${_JAVAVM_PREFIX}/bin/javavm" \
"${_JAVAVM_PREFIX}/bin/`basename "${exe}"`" 2>/dev/null
fi
done
}
#
# Sort the configuration file
#
sortConfiguration () {
local IFS=:
# Ensure the configuration file exists
if [ ! -f "${_JAVAVM_CONF}" ]; then
return
fi
# Ensure the configuration file has the correct permissions
if [ ! -w "${_JAVAVM_CONF}" -o ! -r "${_JAVAVM_CONF}" ]; then
echo "${_JAVAVM_PROG}: error: can't read/write ${_JAVAVM_CONF} configuration file!" 1>&2
return
fi
cat "${_JAVAVM_CONF}" | \
(
export JAVAVMS
while read JAVAVM; do
VM=`echo "${JAVAVM}" | sed -E 's|[[:space:]]*#.*||' 2>/dev/null`
# Check that the VM exists and is "sane"
if [ ! -e "${VM}" ]; then
continue
fi
if [ -d "${VM}" ]; then
continue
fi
if [ ! -x "${VM}" ]; then
continue
fi
if [ `basename "${VM}"` != "java" ]; then
continue
fi
if [ "`realpath "${VM}" 2>/dev/null `" = "${_JAVAVM_PREFIX}/bin/javavm" ]; then
continue
fi
# Skip duplicate VMs
if [ -n "${JAVAVMS}" ]; then
for _JAVAVM in ${JAVAVMS}; do
if [ -z "${_JAVAVM}" ]; then
continue
fi
_VM=`echo "${_JAVAVM}" | sed -E 's|[[:space:]]*#.*||' 2>/dev/null`
if [ "x${VM}" = "x${_VM}" ]; then
continue 2
fi
done
fi
VM=`dirname "${VM}"`
VM=`dirname "${VM}"`
VM=`basename "${VM}"`
_JAVAVMS=:
for _JAVAVM in ${JAVAVMS}; do
if [ -z "${_JAVAVM}" ]; then
continue
fi
if [ -z "${JAVAVM}" ]; then
_JAVAVMS="${_JAVAVMS}:${_JAVAVM}"
continue
fi
_VM=`echo "${_JAVAVM}" | sed -E 's|[[:space:]]*#.*||' 2>/dev/null`
_VM=`dirname "${_VM}"`
_VM=`dirname "${_VM}"`
_VM=`basename "${_VM}"`
# Consistent version numbering for various install directory names
# including 'openjdk6', 'jdk1.6.0', 'linux-sun-jdk1.6.0', etc.
VERSION=`echo ${VM} | sed -e 's|[^0-9]*||' -e 's|1\.||' \
-e 's|\.[0-9]||' 2>/dev/null`
_VERSION=`echo ${_VM} | sed -e 's|[^0-9]*||' -e 's|1\.||' \
-e 's|\.[0-9]||' 2>/dev/null`
if [ "${VERSION}" \> "${_VERSION}" ]; then
_JAVAVMS="${_JAVAVMS}:${JAVAVM}:${_JAVAVM}"
JAVAVM=
continue
elif [ "${VERSION}" \< "${_VERSION}" ]; then
_JAVAVMS="${_JAVAVMS}:${_JAVAVM}"
continue
else
case "${VM}" in
openjdk*)
_JAVAVMS="${_JAVAVMS}:${JAVAVM}:${_JAVAVM}"
JAVAVM=
continue
;;
linux-sun-jdk*|linux-oracle-jdk*)
case "${_VM}" in
open*)
_JAVAVMS="${_JAVAVMS}:${_JAVAVM}"
continue
;;
*)
_JAVAVMS="${_JAVAVMS}:${JAVAVM}:${_JAVAVM}"
JAVAVM=
continue
;;
esac
;;
linux-sun-jre*|linux-oracle-jre*)
case "${_VM}" in
open*|linux-sun*|linux-oracle*)
_JAVAVMS="${_JAVAVMS}:${_JAVAVM}"
continue
;;
*)
_JAVAVMS="${_JAVAVMS}:${JAVAVM}:${_JAVAVM}"
JAVAVM=
continue
;;
esac
;;
esac
_JAVAVMS="${_JAVAVMS}:${_JAVAVM}"
fi
done
JAVAVMS="${_JAVAVMS}"
if [ -n "${JAVAVM}" ]; then
JAVAVMS="${JAVAVMS}:${JAVAVM}"
fi
done;
if [ -n "${JAVAVMS}" ]; then
rm "${_JAVAVM_CONF}"
for JAVAVM in ${JAVAVMS}; do
if [ -n "${JAVAVM}" ]; then
echo "${JAVAVM}" >> "${_JAVAVM_CONF}"
fi
done
fi
)
}
#
# Check all of the VMs in the configuration file
#
checkVMs () {
# Ensure the configuration file exists
if [ ! -f "${_JAVAVM_CONF}" ]; then
exit 0
fi
# Ensure the configuration file has the correct permissions
if [ ! -w "${_JAVAVM_CONF}" -o ! -r "${_JAVAVM_CONF}" ]; then
echo "${_JAVAVM_PROG}: error: can't read/write ${_JAVAVM_CONF} configuration file!" 1>&2
exit 1
fi
# Sort the configuration. This will also remove duplicates and
# non-existent VMs
sortConfiguration
# Ensure links are created for every executable for a VM.
cat "${_JAVAVM_CONF}" | \
(
while read JAVAVM; do
VM=`echo "${JAVAVM}" | sed -E 's|[[:space:]]*#.*||' 2>/dev/null`
# Create symbolic links as appropriate if they don't exist.
JAVA_HOME=`dirname "${VM}"`
JAVA_HOME=`dirname "${JAVA_HOME}"`
createJavaLinks "${JAVA_HOME}"
done;
)
exit 0
}
#
# Register a new Java VM.
#
registerVM () {
# Check the java command given to us.
if [ -z "${1}" ]; then
echo "Usage: ${_JAVAVM_PROG} path"
exit 1
fi
# Create the configuration file if it doesn't exist
if [ ! -e "${_JAVAVM_CONF}" ]; then
touch "${_JAVAVM_CONF}"
fi
# Ensure the configuration file exists and has the correct permissions
if [ ! -f "${_JAVAVM_CONF}" -o ! -w "${_JAVAVM_CONF}" -o ! -r "${_JAVAVM_CONF}" ]; then
echo "${_JAVAVM_PROG}: error: can't read/write ${_JAVAVM_CONF} configuration file!" 1>&2
exit 1
fi
# Check that the given VM can be found in the configuration file
VM=`echo "${1}" | sed -E 's|[[:space:]]*#.*||' 2>/dev/null`
REGISTERED=
if [ -n "`grep "${VM}" "${_JAVAVM_CONF}"`" ]; then
echo "${_JAVAVM_PROG}: warning: JavaVM \"${VM}\" is already registered" 1>&2
REGISTERED="yes"
fi
# Check that the VM exists and is "sane"
if [ ! -e "${VM}" ]; then
echo "${_JAVAVM_PROG}: error: JavaVM \"${VM}\" does not exist" 1>&2
exit 1
fi
if [ -d "${VM}" ]; then
echo "${_JAVAVM_PROG}: error: JavaVM \"${VM}\" is a directory" 1>&2
exit 1
fi
if [ ! -x "${VM}" ]; then
echo "${_JAVAVM_PROG}: error: JavaVM \"${VM}\" is not executable" 1>&2
exit 1
fi
if [ `basename "${VM}"` != "java" ]; then
echo "${_JAVAVM_PROG}: error: JavaVM \"${VM}\" is not valid" 1>&2
exit 1
fi
if [ "`realpath "${VM}" 2>/dev/null `" = "${_JAVAVM_PREFIX}/bin/javavm" ]; then
echo "${_JAVAVM_PROG}: error: JavaVM \"${VM}\" is javavm!" 1>&2
exit 1
fi
# Add the VM to the configuration file
if [ "${REGISTERED}" != "yes" ]; then
echo "${1}" >> "${_JAVAVM_CONF}"
fi
# Create symbolic links as appropriate if they don't exist.
JAVA_HOME=`dirname "${VM}"`
JAVA_HOME=`dirname "${JAVA_HOME}"`
createJavaLinks "${JAVA_HOME}"
# Sort the VMs
sortConfiguration
exit 0
}
#
# Unregister a Java VM.
#
unregisterVM () {
# Check usage
if [ -z "${1}" ]; then
echo "Usage: ${_JAVAVM_PROG} path"
exit 1
fi
# Check for the configuration file
if [ ! -e "${_JAVAVM_CONF}" ]; then
echo "${_JAVAVM_PROG}: error: can't find ${_JAVAVM_CONF} configuration file!" 1>&2
exit 1
fi
# Ensure the configuration file has the correct permissions
if [ ! -w "${_JAVAVM_CONF}" -o ! -r "${_JAVAVM_CONF}" ]; then
echo "${_JAVAVM_PROG}: error: can't read/write ${_JAVAVM_CONF} configuration file!" 1>&2
exit 1
fi
# Check that the given VM can be found in the configuration file
if [ -z "`grep "${1}" "${_JAVAVM_CONF}"`" ]; then
echo "${_JAVAVM_PROG}: error: \"${1}\" JavaVM is not currently registered"
exit 1
fi
# Remove unneeded symlinks
VMS=`sed -E 's|[[:space:]]*#.*||' < "${_JAVAVM_CONF}" | uniq 2>/dev/null`
VM=`grep "${1}" "${_JAVAVM_CONF}" | sed -E 's|[[:space:]]*#.*||' 2>/dev/null`
JAVA_HOME=`dirname "${VM}"`
JAVA_HOME=`dirname "${JAVA_HOME}"`
for exe in "${JAVA_HOME}"/bin/* "${JAVA_HOME}"/jre/bin/*; do
exe=`basename "${exe}"`
if [ -L "${_JAVAVM_PREFIX}/bin/${exe}" -a \
"`realpath "${_JAVAVM_PREFIX}/bin/${exe}" 2>/dev/null `" = \
"${_JAVAVM_PREFIX}/bin/javavm" ]; then
for JAVAVM in ${VMS}; do
if [ "${JAVAVM}" != "${VM}" ]; then
JAVAVM=`dirname "${JAVAVM}"`
JAVAVM=`dirname "${JAVAVM}"`
if [ -x "${JAVAVM}/bin/${exe}" -o \
-x "${JAVAVM}/jre/bin/${exe}" ]; then
continue 2
fi
fi
done
rm "${_JAVAVM_PREFIX}/bin/${exe}"
fi
done
# Remove the VM from the configuration file
ed "${_JAVAVM_CONF}" >/dev/null <<EOF
g|${1}|d
w
q
EOF
# Remove configuration file if its size reached 0
if [ ! -s "${_JAVAVM_CONF}" ]; then
rm "${_JAVAVM_CONF}"
fi
exit 0
}
#
# Show the manual page for a Java VM
#
manualpageVM () {
# Check usage
if [ -z "${1}" ]; then
echo "Usage: ${_JAVAVM_PROG} name"
exit 1
fi
# Look for an appropriate JAVA_HOME
_JAVAVM_SAVE_PROG=${_JAVAVM_PROG}
_JAVAVM_PROG="../man/man1/${1}.1"
setJavaHome
if [ $? != 0 ]; then
echo "${_JAVAVM_SAVE_PROG}: error: no suitable JavaVMs found" 1>&2
exit 1
fi
# Run man(1)
MANPATH="${JAVA_HOME}/man:${MANPATH}"
export MANPATH
if [ "${LANG}" = "ja_JP.eucJP" -a -x "${_JAVAVM_PREFIX}/bin/jman" ]; then
setJavaOptions jman "`basename ${JAVA_HOME}`"
exec ${_JAVAVM_PREFIX}/bin/jman -S 1 ${_JAVAVM_OPTS} ${1}
else
setJavaOptions man "`basename ${JAVA_HOME}`"
exec man -S 1 ${_JAVAVM_OPTS} ${1}
fi
}
#
# Set up an appropriate JAVA_HOME
#
setJavaHome() {
# Use JAVA_HOME if it's set, unless its set to %%PREFIX%%
if [ -n "${JAVA_HOME}" ]; then
if [ "`realpath "${JAVA_HOME}"`" != "`realpath "${_JAVAVM_PREFIX}"`" ]; then
if [ -f "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ]; then
_JAVAVM_PROG_PATH="${JAVA_HOME}/bin"
return 0
elif [ -f "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ]; then
_JAVAVM_PROG_PATH="${JAVA_HOME}/jre/bin"
return 0
fi
fi
fi
unset JAVA_HOME
# Use bsd.java.mk to determine the VM to use if it exists unless
# JAVAVM_FALLBACK_ONLY is set
if [ -z "${JAVAVM_FALLBACK_ONLY}" ]; then
# Determine location of bsd.port.mk if it exists
_JAVAVM_PORTSDIR=
if [ -r /usr/share/mk/bsd.port.mk ]; then
_JAVAVM_PORTSDIR=`"${_JAVAVM_MAKE}" -f /usr/share/mk/bsd.port.mk -V PORTSDIR 2>/dev/null`
fi
_JAVAVM_BSD_PORT_MK=
if [ -n "${_JAVAVM_PORTSDIR}" -a -r "${_JAVAVM_PORTSDIR}/Mk/bsd.port.mk" ]; then
_JAVAVM_BSD_PORT_MK="${_JAVAVM_PORTSDIR}/Mk/bsd.port.mk"
fi
# If bsd.port.mk was found, use that to determine the VM to use.
if [ -n "${_JAVAVM_BSD_PORT_MK}" ]; then
JAVA_HOME=`"${_JAVAVM_MAKE}" -f "${_JAVAVM_BSD_PORT_MK}" -V JAVA_HOME USE_JAVA=yes 2>/dev/null`
if [ -n "${JAVA_HOME}" -a -f "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ]; then
_JAVAVM_PROG_PATH="${JAVA_HOME}/bin"
return 0
elif [ -n "${JAVA_HOME}" -a \
-f "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ]; then
_JAVAVM_PROG_PATH="${JAVA_HOME}/jre/bin"
return 0
fi
fi
fi
# Then try to make sure that ${_JAVAVM_CONF} exists
if [ ! -e "${_JAVAVM_CONF}" ]; then
echo "${_JAVAVM_PROG}: error: can't find ${_JAVAVM_CONF} configuration file" 1>&2
exit 1
fi
# Allow comments in the ${_JAVAVM_CONF}
_JAVAVM_VMS=`sed -E 's|[[:space:]]*#.*||' < "${_JAVAVM_CONF}" | uniq 2>/dev/null`
# Fix up JAVA_VERSION
if [ -n "${JAVA_VERSION}" ]; then
_JAVAVM_VERSION=
for version in ${JAVA_VERSION}; do
case "${version}" in
1.6+)
_JAVAVM_VERSION="${_JAVAVM_VERSION} 1.6 1.7 1.8"
;;
1.7+)
_JAVAVM_VERSION="${_JAVAVM_VERSION} 1.7 1.8"
;;
1.8+)
_JAVAVM_VERSION="${_JAVAVM_VERSION} 1.8"
;;
*)
_JAVAVM_VERSION="${_JAVAVM_VERSION} ${version}"
;;
esac
done
JAVA_VERSION=`echo "${_JAVAVM_VERSION}" | sort | uniq`
fi
# Finally try to run one of the ${_JAVAVM_VMS}
for _JAVAVM_JAVAVM in ${_JAVAVM_VMS}; do
JAVA_HOME=`dirname "${_JAVAVM_JAVAVM}"`
JAVA_HOME=`dirname "${JAVA_HOME}"`
_JAVAVM_VM=`basename "${JAVA_HOME}"`
# Respect JAVA_VERSION
if [ -n "${JAVA_VERSION}" ]; then
_JAVAVM_VERSION=`echo ${_JAVAVM_VM} | \
sed -e 's|^[^0-9]*\([0-9]\)\.\([0-9]\)\.[0-9]$|\1.\2|' \
-e 's|^[^0-9]*\([0-9]\)$|1.\1|'`
for _JAVAVM_REQUESTED_VERSION in ${JAVA_VERSION}; do
if [ "${_JAVAVM_VERSION}" = "${_JAVAVM_REQUESTED_VERSION}" ]; then
_JAVAVM_VERSION=
break
fi
done
if [ -n "${_JAVAVM_VERSION}" ]; then
continue
fi
fi
# Respect JAVA_OS
if [ -n "${JAVA_OS}" ]; then
_JAVAVM_OS=
case "${_JAVAVM_VM}" in
openjdk*)
_JAVAVM_OS=native
;;
linux*)
_JAVAVM_OS=linux
;;
esac
for _JAVAVM_REQUESTED_OS in ${JAVA_OS}; do
if [ "${_JAVAVM_OS}" = "${_JAVAVM_REQUESTED_OS}" ]; then
_JAVAVM_OS=
break
fi
done
if [ -n "${_JAVAVM_OS}" ]; then
continue
fi
fi
# Respect JAVA_VENDOR
if [ -n "${JAVA_VENDOR}" ]; then
_JAVAVM_VENDOR=
case "${_JAVAVM_VM}" in
openjdk*)
_JAVAVM_VENDOR=openjdk
;;
linux-sun*)
_JAVAVM_VENDOR=sun
;;
linux-oracle*)
_JAVAVM_VENDOR=oracle
;;
esac
for _JAVAVM_REQUESTED_VENDOR in ${JAVA_VENDOR}; do
if [ "${_JAVAVM_VENDOR}" = "${_JAVAVM_REQUESTED_VENDOR}" ]; then
_JAVAVM_VENDOR=
break
fi
done
if [ -n "${_JAVAVM_VENDOR}" ]; then
continue
fi
fi
# Check if the command exists
if [ -n "${JAVA_HOME}" -a -f "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ]; then
_JAVAVM_PROG_PATH="${JAVA_HOME}/bin"
return 0
elif [ -n "${JAVA_HOME}" -a \
-f "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ]; then
_JAVAVM_PROG_PATH="${JAVA_HOME}/jre/bin"
return 0
fi
done
unset JAVA_HOME
return 1
}
# Check for an alias and call the appropriate function.
case "${_JAVAVM_PROG}" in
registervm )
registerVM "${1}"
;;
unregistervm )
unregisterVM "${1}"
;;
checkvms )
checkVMs
;;
manvm )
manualpageVM "${1}"
;;
esac
# Main ()
# Backwards compatibility
if [ "${_JAVAVM_PROG}" = "javavm" ]; then
echo "${_JAVAVM_PROG}: warning: The use of 'javavm' as a synonym for 'java' is deprecated" 1>&2
_JAVAVM_PROG=java
fi
# Initialise options
if [ -r "${_JAVAVM_OPTS_CONF}" ]; then
. "${_JAVAVM_OPTS_CONF}"
fi
_JAVAVM_OPTS=
# Determine JAVA_HOME
setJavaHome
if [ $? != 0 ]; then
echo "${_JAVAVM_PROG}: error: no suitable JavaVMs found" 1>&2
exit 1
fi
# Set up the options and run the command
if [ -x "${_JAVAVM_PROG_PATH}/${_JAVAVM_PROG}" ]; then
setJavaOptions "${_JAVAVM_PROG}" "`basename ${JAVA_HOME}`"
export JAVA_HOME
tryJavaCommand "${_JAVAVM_PROG_PATH}/${_JAVAVM_PROG}" ${_JAVAVM_OPTS} "${@}"
fi
echo "${_JAVAVM_PROG}: error: no suitable JavaVMs found" 1>&2
exit 1

View File

@@ -0,0 +1,136 @@
.\"
.\" Copyright (C) 2006 Greg Lewis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: head/java/javavmwrapper/src/manvm.1 340872 2014-01-24 00:14:07Z mat $
.\"
.Dd June 12, 2006
.Os
.Dt MANVM 1
.Sh NAME
.Nm manvm
.Nd format and display the on-line Java VM manual pages
.Sh SYNOPSIS
.Nm
.Op Ar name
.Sh DESCRIPTION
.Nm Manvm
provides a convenient system for displaying the on-line manual pages
for different Java VMs without having to add their (conflicting) manual
page directories to
.Ev MANPATH
.Pp
By default,
.Nm
will select the most
.Dq native
and up to date version of the Java VM when locating the manual page to
be displayed.
This selection process is akin to that used by
.Nm javavm
in that the same environment variables and processes are used.
.Pp
The manual pages are displayed using
.Nm man ,
and all applicable environment variables, save for
.Ev MANPATH ,
are respected.
Options may be passed to
.Nm man
using the
.Ev JAVAVM_OPTS
environment variable and its associated sub-variables and configuration
file.
.Sh ENVIRONMENT
.Bl -tag -width indent
.It Ev JAVA_HOME
The presence of this variable in the environment when executing
.Nm
will override all other considerations regarding the Java VM whose on-line
manual pages will be displayed and the manual pages located at
.Pa ${JAVA_HOME}/man
will be used.
.Pp
.It Ev JAVA_OS
A space delimited list of operating systems.
The on-line manual pages to be displayed must come from a Java VM that has
been created for one of the operating systems in the list.
.Pp
Currently allowed operating system values are
.Ql native
and
.Ql linux .
.It Ev JAVA_VENDOR
A space delimited list of Java VM vendors.
The on-line manual pages to be displayed must come from a Java VM that has
been released by one of the vendors in the list.
.Pp
Currently allowed vendors are
.Ql bsdjava ,
.Ql freebsd ,
.Ql openjdk
and
.Ql sun .
.It Ev JAVA_VERSION
A space delimited list of versions of the Java VM from which the on-line
manual pages may come.
By appending a
.Ql +
to a version, the on-line manual pages from any Java VM with a version
greater than or equal to the given version will be used.
.Pp
Currently allowed versions are
.Ql 1.5 ,
.Ql 1.5+ ,
.Ql 1.6 ,
.Ql 1.6+ ,
.Ql 1.7
and
.Ql 1.7+ .
.It Ev JAVAVM_OPTS
The contents of this environment variable will be passed to the invoked
.Nm man
as options.
For more information on environment variables which can be used to set
options see
.Pa %%PREFIX%%/etc/javavm_opts.conf.dist .
.El
.Sh EXAMPLES
.Bl -tag -width indent
.It Pa %%LOCALBASE%%/bin/manvm java
Display the on-line manual page for the
.Nm java
programme of the the most up to date and
.Dq native
Java VM registered with
.Nm javavm .
.It Ev JAVA_VERSION=1.5 Pa %%LOCALBASE%%/bin/manvm javac
Display the on-line manual page for the
.Nm javac
programme for a Java VM which is version 1.5.
.El
.Sh SEE ALSO
.Xr javavm 1 ,
.Xr man 1 ,
.Xr javavm_opts.conf 5

View File

@@ -0,0 +1,80 @@
.\"
.\" Copyright (C) 2005 Greg Lewis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: head/java/javavmwrapper/src/registervm.1 340872 2014-01-24 00:14:07Z mat $
.\"
.Dd February 24, 2005
.Os
.Dt REGISTERVM 1
.Sh NAME
.Nm registervm ,
.Nm unregistervm
.Nd register/unregister a Java VM
.Sh SYNOPSIS
.Nm
.Ar /path/to/java
.Nm unregistervm
.Ar /path/to/java
.Sh DESCRIPTION
The
.Nm registervm
and
.Nm unregistervm
utilities allow a Java VM to be registered and unregistered as a possible
Java VM that
.Nm javavm
can use.
The registration process places the registered VM in the Java VM wrapper
configuration file in sorted order.
When unregistering the Java VM is removed from the Java VM wrapper
configuration file and will no longer be a possible choice for
.Nm javavm .
.Sh FILES
.Bl -tag -width indent
.It Pa %%PREFIX%%/etc/javavms
The location of the Java VM wrapper configuration file.
.El
.Sh EXAMPLES
.Bl -tag -width indent
.It %%PREFIX%%/bin/registervm %%LOCALBASE%%/jdk1.6.0/bin/java
Register %%LOCALBASE%%/jdk1.6.0/bin/java as a possible choice of
Java VM for
.Nm javavm .
.It %%PREFIX%%/bin/unregistervm %%LOCALBASE%%/jdk1.6.0/bin/java
Remove %%LOCALBASE%%/jdk1.6.0/bin/java as a possible choice of
Java VM for
.Nm javavm .
.El
.Sh SEE ALSO
.Xr checkvms 1 ,
.Xr javavm 1 ,
.Xr javavms 5
.Sh BUGS
The
.Nm
and
.Nm unregistervm
utilities remove both blank lines and purely comment lines from
the Java VM wrapper configuration file.

View File

@@ -0,0 +1,4 @@
The Java VM wrapper provides a convenient system for switching between
different Java VMs. It also provides symbolic links in ${PREFIX}/bin to
allow the use of the Java executables without having to add the specific
Java VM executable directories to the PATH environment variable.

View File

@@ -0,0 +1,14 @@
bin/checkvms
bin/classpath
bin/javavm
bin/manvm
bin/registervm
bin/unregistervm
man/man1/checkvms.1.gz
man/man1/javavm.1.gz
man/man1/manvm.1.gz
man/man1/registervm.1.gz
man/man1/unregistervm.1.gz
man/man5/javavm_opts.conf.5.gz
man/man5/javavms.5.gz
@dir share/examples/javavmwrapper