# Java the weed

Java is like a weed: a plant whose growth cannot be controlled. As in real life, you have to check from time to time where it has installed itself and you have to remove it manually, because - at least in my Windows machine - not one JAVA SDK is listed under Apps.

The problem with that is that you never know which Java SDK (or run-time) is used when you use Java. The first one installed, the last one installed, the one with the highest version number ... what if there are two distributions with the same version, which one is updated automatically and so on.&#x20;

{% hint style="danger" %}
To avoid unpredictable and unexpected results when using IntelliJ with Groovy \
you must control your Java installations!&#x20;
{% endhint %}

## Observations

One day, I recognized a growing list of SDKs in my IntelliJ project:

<figure><img src="/files/lXVigErphfAxzxRjmaOT" alt=""><figcaption><p>Java SDKs in the project - found and added by IntelliJ </p></figcaption></figure>

The first action I took was to search for "java.exe" which gave me some insight where to look for weed.

<figure><img src="/files/ty6euwYrKq4sFn0LSu3e" alt=""><figcaption><p>Searching for "java.exe" - using <a href="https://www.voidtools.com/downloads/">Everything</a></p></figcaption></figure>

Alternatively, on Windows you can run `where /R groovy.bat` and `where /R java.exe` to find all SDK locations on your machine.

Actually, I wanted&#x20;

* **one** Java SDK and distribution (I use Amazon Corretto v23)
* the ATOM SDK: `C:\Program Files\Boomi AtomSphere\LocalAtom\jre\bin`&#x20;
* Some applications, especially JetBrains Apps like IntelliJ, install their own, local run-time,, which you will want to keep!

### Confusion

{% hint style="info" %}
There is no other way to check for Java installations on your machine then searching for "java.exe" - omg!
{% endhint %}

You may use `where java` on the command-line or you want to check the `JAVA_HOME` environment variable:

```
C:\> where java
C:\Program Files\Amazon Corretto\jdk21.0.6_7\bin\java.exe

C:\> set JAVA_HOME
JAVA_HOME=C:\Users\marku\.jdks\corretto-23.0.1
```

and you will be confused even more!

<figure><img src="/files/sUzeE6t65NacAqjPfiAM" alt=""><figcaption><p>Nothing is listed under "Apps" (Windows)</p></figcaption></figure>

### Get rid of it

{% hint style="info" %}
Close IntelliJ and all other applications that might lock Java.
{% endhint %}

* Pick all the paths containing a *java.exe* which you don't want.
* Delete these directories using a **console window with ADMIN rights**.

<pre><code><strong>rmdir /s /q "C:\Program Files\Amazon Corretto\jdk21.0.6_7\bin\"
</strong>rmdir /s /q "C:\Users\marku\.jdks\corretto-23.0.1\bin"
rmdir /s /q "C:\Users\marku\.jdks\corretto-23.0.2\bin"
rmdir /s /q "C:\Users\marku\.jdks\jbr-17.0.12\bin"
rmdir /s /q "C:\Users\marku\.jdks\openjdk-23.0.1\bin"
</code></pre>

<details>

<summary>Gradle</summary>

Gradle is a Java  build tool. You may have it or not but you may notice it is **even worse than Java:**

<figure><img src="/files/cyIGBlSDBrxWPwNuuYDh" alt=""><figcaption><p>.gradle Cache files</p></figcaption></figure>

I delete my `.gradle` cache folder from time to time (incl. the included Java distributions) to get a fresh Gradle setup: `rmdir /s /q "V:\packages\.gradle"`. The next time I use Gradle it downloads and installs back automatically but I got rid of all the old and unused versions that were littering my computer.

For example, the *ScriptEaseLib* is built with Gradle. Every time I build it, the Gradle toolchain is downloaded if it does not exist. It takes a minute or two ...

<figure><img src="/files/GDhGG5z1ZRuxV9PysDHA" alt=""><figcaption><p>Gradle is downloading</p></figcaption></figure>

</details>

## Clean! Start over! Clean install!

* Close all JAVA apps
* Close IntelliJ
  * Close all JetBrains apps, incl. ToolBox
* Check Task Manager that Java isn't running anymore
* Alternatively: log-off and log-on again

Find your preferred distribution, for example: [Amazon Corretto 23](https://docs.aws.amazon.com/corretto/latest/corretto-23-ug/downloads-list.html).

Ensure you are running a complete installation incl. environment variables etc.\
![](/files/cwRMxtwnGLDBnAmdLmMp)

Unfortunately there are two (Windows) environment variables: for the current user and for *system.* The user setting has preference and the Corretto installation sets the system variable. Delete the user's JAVA\_HOME and go with the just installed system setting:&#x20;

<figure><img src="/files/h43qB66oRO5JUg5V7nPy" alt=""><figcaption><p>Windows environment settings</p></figcaption></figure>

### Fix IntelliJ

IntelliJ will now list orphaned references:

<figure><img src="/files/gIWuL3FQBcTW9nV4EX2S" alt=""><figcaption><p>Orphaned Java SDKs in IntelliJ</p></figcaption></figure>

* Leave the ATOM JDK and remove all other entiries.
* Add the one and only that you have just installed

<figure><img src="/files/C1e5RdUWcjMM47M5re1r" alt=""><figcaption></figcaption></figure>

* Fix your *Project Settings*

<figure><img src="/files/j7cDcBztozVAdWWknso9" alt=""><figcaption></figcaption></figure>

\* Make sure all your modules (normally there is only one) use the *Project SDK*

<figure><img src="/files/wJVHyo77XcmrdCh6AQml" alt=""><figcaption></figcaption></figure>

## Final Checks

**Open a new console window!** \
If you had an open console, this has not recognized all the changes you made!

```
c:\> where java
C:\Program Files\Amazon Corretto\jdk23.0.2_7\bin\java.exe

c:\> set JAVA_HOME
JAVA_HOME=C:\Program Files\Amazon Corretto\jdk23.0.2_7
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boomi.markusschmidt.pro/boomi-scriptease/troubleshoot/java-the-weed.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
