users@jaxb.java.net

Re: does the RI installer invoke a jvm with "java"?

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Thu, 06 Oct 2005 10:58:47 -0700

jonathan gold wrote:
> the java in /usr/bin/ is in fact 1.4.2_05 (standard apple port of
> hotspot), so this made sense. i confirmed the same on my linux machine
> -- the installer seemed to invoke /usr/bin/java, which doesn't work.

The installer is just a jar file, so which JVM is used to run it
entirely depends on the way your OS set up. I don't have a Mac so I
don't know how it works, but for example in Windows it runs a java
associated with '.jar' extension, which tends to be the last JDK/JRE
installed.

Of course if you just run "java -jar ..." then it depends on your PATH.

> not sure how the installer works, but if there's an exec of
> "/usr/bin/java", or if it allows the shell to pick the "best" java from
> the user's $PATH, i think that might be worth a look. maybe try to use
> $JAVA_HOME/bin/java first, if that variable is set?

When you run xjc.sh or schemagen.sh, it tries to run $JAVA_HOME/bin/java
if $JAVA_HOME is set, otherwise I think it just runs "java". So again it
depends on your environment. You can see this process by running:

$ sh -x xjc.sh ..

I don't know if it's possible for a shell script to check for multiple
java executables in your PATH and pick the right one. It seems to be too
complicated, although I could be wrong.

> incidentally, i got the installer to run by creating a fake
> /usr/bin/java that symlinked to my $JAVA_HOME/bin/java, and then fixing
> the link after the installer ran. couldn't have done that if i didn't
> have sudo though...
>
> i tried a couple of queries on issue tracker, but everything came back
> with no results (i'm still a bit bewildered by those types of query
> forms:), so my apologies if this is a dup.

Thanks for checking the archive first!

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com