Re: Correct way to load jvm.dll in a JNI application?
Elena wrote:
I understand that, but then which is a proper way to locate Java from
a native application?
If it's not in the PATH or the JAVA_HOME, you have to let the user configure
it or give up. If PATH and JAVA_HOME disagree, just pick one. jolz has
already answered your questions.
That is: they are not aligned (1.6.0_13 vs 1.6.0_02) and JAVA_HOME is
older. That's why I'm looking into the registry to find more recent
JVM's path.
You don't have to find the most recent Java version. You just have to find a
Java version. The user might not want your app to use the most recent version.
Moreover, having developed an application which relies on Java 1.6,
should I demand a JRE 1.6 or a JRE 1.6 or higher (that is: 1.7, ecc.)?
The "version or higher" choice, obviously.
jolz wrote:
Trying to guess correct JVM location is a good idea but you should
consider to let end user configure the location.
Elena wrote:
That would be a pragmatic solution. Thanks.
What others have told you: to get the very latest Java on a system, you really
cannot rely on the registry. You cannot rely on JAVA_HOME. You can perhaps
rely on PATH, but not necessarily. In short, there is no programmatic way to
get the latest Java version. Beyond what they told you, if the user has made
some version of Java available through one of those mechanisms, you can use
that one. It need not be the latest if it meets your minimum. If none
suitable are found, you can ask (not demand) the user to provide one, or you
can give up.
--
Lew