Skip to content

Commit

Permalink
Clarify JAVA_HOME for MacOS users
Browse files Browse the repository at this point in the history
  • Loading branch information
CedNaru committed Jan 21, 2025
1 parent 9819350 commit 98e550d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/src/doc/getting-started/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ To use this module at least JDK 11 is needed, note you will need the JDK not jus

You can install Java via [SDKMAN!](https://sdkman.io/). Once you installed it, you can run `sdk install java 11.0.11.hs-adpt` to install the LTS version of Java from [AdoptOpenJDK](https://adoptopenjdk.net/). If you want to pick a different version, you can run `sdk list java`.

!!! warning
On macOS apps started from the GUI cannot see environment variables from bash or zsh, only command line apps can. Set environment variable using launchctl.
```shell
launchctl setenv JAVA_HOME pathtoyourjava
```

### Windows

You can install Java via [Chocolatey](https://community.chocolatey.org/). For example, to install [AdoptOpenJDK](https://adoptopenjdk.net/) you can run `choco install adoptopenjdk11`.
Expand Down
15 changes: 13 additions & 2 deletions src/gd_kotlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,22 @@ void GDKotlin::validate_state() {
if (state == State::NOT_STARTED) {
invalid = true;
#ifdef DYNAMIC_JVM
#ifdef MACOS_ENABLED
if (user_configuration.vm_type == jni::JVM) {
cause = "Couldn't open JVM dynamic library.";
hint =
"Make sure the JAVA_HOME environment variable is set or add an embedded JRE to your project using jlink.";
} else if (user_configuration.vm_type == jni::GRAAL_NATIVE_IMAGE) {
"The environment variable JAVA_HOME is not found and there is no embedded JRE. If you "
"launched the editor through a double click on Godot.app, also make sure that JAVA_HOME "
"is set through launchctl: `launchctl setenv JAVA_HOME </path/to/jdk>`";
}
#else
if (user_configuration.vm_type == jni::JVM) {
cause = "Couldn't open JVM dynamic library.";
hint =
"Make sure the JAVA_HOME environment variable is set or add an embedded JRE to your project using jlink.";
}
#endif
else if (user_configuration.vm_type == jni::GRAAL_NATIVE_IMAGE) {
cause = "Couldn't open Graal Native Image.";
hint = "Make sure you have built your JVM project with Graal native image enabled in your gradle build.";
}
Expand Down

0 comments on commit 98e550d

Please sign in to comment.