Discussion:
Set path to JRE / JDK in code
Petrus Hyvönen
2015-01-20 15:28:09 UTC
Permalink
Hi,

I'm trying to package a wrapped library together with a non system-wide
java JDK so that it can be easily installed.

Can I somehow direct which JDK to use besides using JCC_JDK and putting the
JRE in the PATH (I'm currently under windows)? The JCC_JDK could be patched
in the setup.py but the PATH JRE that is accessed during running the
wrapped library I don't understand where it is accessed, or how to patch
this?

For example it would be good to have this in the config.py file if
possible?

Any thoughts or someone who's done this already?

Regards
/Petrus
--
_____________________________________________
Petrus Hyvönen, Uppsala, Sweden
Mobile Phone/SMS:+46 73 803 19 00
Andi Vajda
2015-01-20 18:14:30 UTC
Permalink
Post by Petrus Hyvönen
Hi,
I'm trying to package a wrapped library together with a non system-wide
java JDK so that it can be easily installed.
Can I somehow direct which JDK to use besides using JCC_JDK and putting the
JRE in the PATH (I'm currently under windows)? The JCC_JDK could be patched
in the setup.py but the PATH JRE that is accessed during running the
wrapped library I don't understand where it is accessed, or how to patch
this?
So you're asking how to control where to pickup the JRE DLLs (on Windows) at
runtime ? If I remember correctly, on Windows you just set the Path
environment variable, no ?
Post by Petrus Hyvönen
For example it would be good to have this in the config.py file if
possible?
If you're sure config.py is run _before_ any JRE DLL is loaded, you might be
able to change the Path fron there too.

Andi..
Post by Petrus Hyvönen
Any thoughts or someone who's done this already?
Regards
/Petrus
--
_____________________________________________
Petrus Hyvönen, Uppsala, Sweden
Mobile Phone/SMS:+46 73 803 19 00
Petrus Hyvönen
2015-01-21 10:34:32 UTC
Permalink
Hi,

It is primary on my "wrapped" library that this applies, for so it can be
easily installed.

Yes on windows the JRE is found using the PATH. I haven't been able to
locate where this is done, as I would prefer to use a direct variable or
separate environment variable for this to keep it "boxed" from the system
variables.

I have however found a way now that works fine based on updating the PATH
as a first thing in the __init__.py file in the wrapped library by
prepending:

import os
os.environ["PATH"] = r"mypath\jre\bin\server" + os.pathsep +
os.environ["PATH"]

the installer takes care of updating the path to the right place later on.

Many thanks
/Petrus
Post by Andi Vajda
Hi,
Post by Petrus Hyvönen
I'm trying to package a wrapped library together with a non system-wide
java JDK so that it can be easily installed.
Can I somehow direct which JDK to use besides using JCC_JDK and putting the
JRE in the PATH (I'm currently under windows)? The JCC_JDK could be patched
in the setup.py but the PATH JRE that is accessed during running the
wrapped library I don't understand where it is accessed, or how to patch
this?
So you're asking how to control where to pickup the JRE DLLs (on Windows)
at runtime ? If I remember correctly, on Windows you just set the Path
environment variable, no ?
For example it would be good to have this in the config.py file if
Post by Petrus Hyvönen
possible?
If you're sure config.py is run _before_ any JRE DLL is loaded, you might
be able to change the Path fron there too.
Andi..
Post by Petrus Hyvönen
Any thoughts or someone who's done this already?
Regards
/Petrus
--
_____________________________________________
Petrus Hyvönen, Uppsala, Sweden
Mobile Phone/SMS:+46 73 803 19 00
--
_____________________________________________
Petrus Hyvönen, Uppsala, Sweden
Mobile Phone/SMS:+46 73 803 19 00
Loading...