[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#163390: JNI Installation Directories (again)



> > Sure.  If nothing else, you can do it by replacing your java runtime
> > command with a short startup script that looks for
> > -Djava.library.path=foo on the
>
> And this works with kaffe, ibm-jdk, blackdown and sun jdk?

It'll work with any Java runtime that supports -Djava.library.path, but they 
all should support this since it's the standard way to specify a JNI search 
path.

> This have to be mentioned in policy. Or maybe not. It should be quite
> obvious that you have to make such things.

I wouldn't want to force such a script on JVM maintainers; if they prefer to 
hard-code the debian JNI path in the JVM sources (as a debian patch) then 
that's cool with me.  I'm happy just to include a reference to such a script 
in whatever bugs end up being filed on the various JVMs.

I've written a perl script that does what I mentioned; it can be used as the 
JVM's primary runtime command.  It merely fixes the JNI search path and 
passes everything straight through to the real java runtime.

The script is below.

Ben.

#!/usr/bin/perl -w
#
# Starts a java runtime, ensuring that the debian JNI module directory is on
# the JNI search path.
#
# Variable $javaRuntime should be modified to suit the particular java
# runtime being used.
#
# Usage: As for the particular java runtime being used.
#
# Copyright (C) 2002 by Ben Burton <benb@acm.org>

use strict;

# The real java runtime:
my $javaRuntime = '/usr/bin/myjavaruntime';

# The debian JNI module directory:
my $debianJNIDir = '/usr/lib/jni';

# The command-line options to pass to the real java runtime:
my @commandLine;

# The full JNI search path to use:
my $JNIPath = '';

# Build the command-line from the arguments given.
foreach my $arg (@ARGV) {
  if ($arg =~ /^-Djava.library.path=(.+)$/) {
    # A component of the JNI search path has been given.
    if ($JNIPath) {
      $JNIPath = $JNIPath . ':' . $1;
    } else {
      $JNIPath = $1;
    }
  } else {
    # Some other argument has been given.
    push @commandLine, $arg;
  }
}

# Add the debian JNI module directory to the JNI search path if it's not
# already there.
if ($JNIPath !~ /(^|:)$debianJNIDir($|:)/) {
  if ($JNIPath) {
    $JNIPath = $JNIPath . ':' . $debianJNIDir;
  } else {
    $JNIPath = $debianJNIDir;
  }
}

# Call the real Java runtime.
my @fullCommandLine = ( $javaRuntime, "-Djava.library.path=$JNIPath" );
push @fullCommandLine, @commandLine;
exec @fullCommandLine or exit(1);





Reply to: