3
# Starts the GNU Java interpreter.
5
# Command-line arguments should be in the style of Sun's Java runtime;
6
# these will be converted to gij arguments before being passed to the
9
# The Debian JNI module directory and any other specified JNI
10
# directories will be included on the JNI search path.
12
# Copyright (C) 2002-2003 by Ben Burton <bab@debian.org>
13
# Based on the original gij-wrapper-3.2 shell script.
17
# The real Java runtime:
18
my $javaRuntime = '/usr/bin/gij-@BV@';
20
# The debian JNI module directory:
21
my $debianJNIDir = '/usr/lib/jni';
23
# The command-line arguments to pass to the real Java runtime:
26
# The full JNI search path to use:
29
# Build the command-line from the arguments given.
30
my $parsingOptions = 1;
32
# Flag used to copy argument to -classpath or -cp.
34
foreach my $arg (@ARGV) {
35
if (not $parsingOptions) {
36
# We're done parsing options; just copy all remaining arguments directly.
37
push @commandLine, $arg;
41
push @commandLine, $arg;
46
# Try to interpret Sun-style options.
47
if ($arg eq '-version') {
48
push @commandLine, '--version';
49
} elsif ($arg eq '-h' or $arg eq '-help') {
50
push @commandLine, '--help';
51
} elsif ($arg eq '-cp' or $arg eq '--cp') {
52
push @commandLine, '-cp';
54
} elsif ($arg eq '-classpath' or $arg eq '--classpath') {
55
push @commandLine, '-classpath';
57
} elsif ($arg =~ /^-Djava.library.path=(.+)$/) {
58
# A component of the JNI search path has been given.
60
$JNIPath = $JNIPath . ':' . $1;
64
} elsif ($arg eq '-jar' or $arg =~ /^-D/) {
65
# Copy the argument directly.
66
push @commandLine, $arg;
67
} elsif ($arg =~ /^-/) {
68
# An unrecognised option has been passed - just drop it.
70
# Some non-option argument has been given.
71
# Stop parsing options at this point.
72
push @commandLine, $arg;
77
# Add the debian JNI module directory to the JNI search path if it's not
79
if ($JNIPath !~ /(^|:)$debianJNIDir($|:)/) {
81
$JNIPath = $JNIPath . ':' . $debianJNIDir;
83
$JNIPath = $debianJNIDir;
87
# Use environment variable $LTDL_LIBRARY_PATH to store the JNI path,
88
# since gij uses libltdl to dlopen JNI modules.
89
if ($ENV{LTDL_LIBRARY_PATH}) {
90
$ENV{LTDL_LIBRARY_PATH} = $ENV{LTDL_LIBRARY_PATH} . ':' . $JNIPath;
92
$ENV{LTDL_LIBRARY_PATH} = $JNIPath;
95
# Call the real Java runtime.
96
my @fullCommandLine = ( $javaRuntime );
97
push @fullCommandLine, @commandLine;
98
exec @fullCommandLine or exit(1);