Java library problems

Windows 10 environment.

Installed Java SE Development Kit 23.0.1

Set system environment variable JAVA_HOME = C:\Program Files\Java\jdk-23\bin
(earlier i set it to JAVA_HOME = C:\Program Files\Java\jdk-23 and it had the same problem

(base) C:\Users\chivo>conda activate adore

(adore) C:\Users\chivo>python
Python 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import py5
Error occurred during initialization of VM
Could not find agent library instrument on the library path, with error: Can't find dependent libraries
Module java.instrument may be missing from runtime image.

At a dead-end here. I am trying to install py5 so that I can use it in my jupyter notebook world.

Besides these 3 standard command-line troubleshoot checks:

  1. echo %JAVA_HOME%
  2. where java
  3. java -version

We can run the “System Properties” in order to edit the “Environment Variables”:
%SystemRoot%\System32\SystemPropertiesAdvanced.exe

The “Environment Variables” is split in 2 parts: “User” & “Sys” vars.

Make sure var JAVA_HOME is set on both parts and has this string value:
%ProgramFiles%\Java\jdk-23\bin
%ProgramFiles%\Java\jdk-23

In my laptop it’s %ProgramFiles%\Java\jdk-21 b/c that’s my current Java version.

After setting the var JAVA_HOME in both places, access the var Path on the “User” section.

If it doesn’t exist yet, add %JAVA_HOME%\bin as 1 of its entries, and move it up, making sure it’s 1 of the top entries.

You can also add a %CommonProgramFiles%\Oracle\Java\javapath entry to the Path, which is a folder containing the default Java version’s basic executables.

Now do the same for the “Sys” section and you’re done.

If you prefer, you can restart Windows to make sure those changes will take effect.

Now I believe import py5 should be able to find your JDK Java; let’s hope so. :crossed_fingers:


EDIT: Chat AI stated we shouldn’t use “\bin” for the JAVA_HOME variable!

So you should just use %ProgramFiles%\Java\jdk-23 as the JAVA_HOME value.

Then add it as a var “Path” entry like this: %JAVA_HOME%\bin

1 Like

Thanks

So my fix was:

  1. uninstalled all the java stuff i installed, etc.
  2. Somehow i missed the more elaborate instructions at Install py5 — py5 documentation I created a new environment based on http://py5coding.org/files/install/py5_environment.yml
  3. pip install install-jdk and jdk.install(‘17’)
  4. it still didn’t work, so I had to create JAVA_HOME env var
  5. it still didn’t work, so I added JAVA_HOME to my PATH as well
    Then it works…
1 Like

Sometimes we do need drastic measures!
Nonetheless, I have py5 working w/ a regular Oracle’s JDK system-wide installation on Win10:


>java -version

java version “21.0.2” 2024-01-16 LTS
Java™ SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot™ 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)


>where javac

C:\Program Files\Java\jdk-21\bin\javac.exe
C:\Program Files\Common Files\Oracle\Java\javapath\javac.exe


>echo %JAVA_HOME%
C:\Program Files\Java\jdk-21


And this is “jdk21-openjdk” installed package on my Garuda Linux (Arch-based distro):


>java -version

openjdk version “21.0.5” 2024-10-15
OpenJDK Runtime Environment (build 21.0.5+11)
OpenJDK 64-Bit Server VM (build 21.0.5+11, mixed mode, sharing)


>which javac
/usr/bin/javac


>echo $JAVA_HOME
/usr/lib/jvm/default


1 Like

Be aware all those packages minimum versions are too old, especially “numpy”!
And its “python=3.11” entry is already old too, considering current 1 is 3.13!

JDK-17 is the previous LTS version. Current Java is JDK-23, and current LTS is JDK-21!

I was mistaken about adding the subfolder “\bin”. Edit it so it doesn’t have that anymore.

After removing the “\bin” from sys var %JAVA_HOME%, its entry in PATH should now include it:
%JAVA_HOME%\bin

2 Likes