# Java library problems

**URL:** <https://discourse.processing.org/t/java-library-problems/45377>\
**Category:** py5\
**Created:** [November 23, 2024, 1:11pm UTC](https://discourse.processing.org/t/java-library-problems/45377 "2024-11-23T13:11:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![slashwreck](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@slashwreck](https://discourse.processing.org/u/slashwreck)\
**Post date:** [November 23, 2024, 1:11pm UTC](https://discourse.processing.org/t/java-library-problems/45377/1 "2024-11-23T13:11:10Z")

</div>

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

```auto
(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.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [November 23, 2024, 5:56pm UTC](https://discourse.processing.org/t/java-library-problems/45377/2 "2024-11-23T17:56:28Z")

</div>

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. 🤞

* * *

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`

---

<div class="post-metadata">

**Author:** ![slashwreck](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@slashwreck](https://discourse.processing.org/u/slashwreck)\
**Post date:** [November 24, 2024, 2:37am UTC](https://discourse.processing.org/t/java-library-problems/45377/3 "2024-11-24T02:37:17Z")

</div>

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](https://py5coding.org/content/install.html) 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…

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [November 24, 2024, 12:39pm UTC](https://discourse.processing.org/t/java-library-problems/45377/4 "2024-11-24T12:39:18Z")

</div>

> [@slashwreck](#):
>
> 1. Uninstalled all the Java stuff I installed, etc.

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](https://garudalinux.org) ([Arch](https://archlinux.org)-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

* * *

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [November 24, 2024, 3:40pm UTC](https://discourse.processing.org/t/java-library-problems/45377/5 "2024-11-24T15:40:47Z")

</div>

> [@slashwreck](#):
>
> 1. [http://py5Coding.org/files/install/py5\_environment.yml](http://py5Coding.org/files/install/py5_environment.yml)

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!

> [@slashwreck](#):
>
> 1. pip install install-jdk and `jdk.install('17')`.

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

> [@slashwreck](#):
>
> 1. It still didn’t work, so I had to create JAVA\_HOME env var

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

> [@slashwreck](#):
>
> 1. It still didn’t work, so I added `%JAVA_HOME%` to my PATH as well. Then it works…

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