Terasology: Support for OpenJDK on Windows

Created on 4 Nov 2019  路  10Comments  路  Source: MovingBlocks/Terasology

What you were trying to do

Trying to launch Terasology with OpenJDK 8 on Windows will result on the next message being displayed instead.
Launched directly from the exe, didn't use TerasologyLauncher.

No Java Installation Found
Could not find a suitable Java 8 installation on your computer.

imagen

OpenJDK binaries are jdk8u232-b09 got from https://adoptopenjdk.net/?variant=openjdk8&jvmVariant=hotspot
I develop with these, so I'm sure javapath is correctly set.

Game version

Tried TerasologyOmega Alpha 12 and Alpha 13 RC, and none of them work.

Bug

All 10 comments

Thanks for reporting! I'm not absolutely sure, but the runtime detection is probably done in:

https://github.com/MovingBlocks/TerasologyJavaLauncher/blob/master/terasology.cpp#L43-L50

 if (jreHome.empty()) { 
    // User installation error will be reported by detectJre 
    if (config.jreDirectory().empty()) { 
        Platform::showError("No Java Installation Found", 
            "Could not find a suitable Java 8 installation on your computer."); 
    } 
    return -1; 
 }

It migth be looking for JAVA_HOME or JavaHome in your environment.

Are there any other logging outputs when starting the game from the .exe?

As I said, JAVA_HOME and Path are correctly set:
imagen
The installer for OpenJDK takes care of it during installation.

And from what I can tell, no log seems to be created.
Where the exe is located, no log can be found, and %AppData%/Terasology does not exist on my system.

This definitely does not behave as it should... maybe we are checking against some Oracle-specific names which are not met by the AdoptOpenJDK distribution 馃
I'm not sure how the lookup in CRegKey deals with case sensitivity and underscores, but this line defines a string constant to "JavaHome": https://github.com/MovingBlocks/TerasologyJavaLauncher/blob/master/jredetector_win.cpp#L14

I'll try to reproduce the issue locally... Maybe @jdrueckert could help, I think she also uses AdoptOpenJDK...

I can confirm (not with AdoptOpenJDK, though) that the exe is not working 馃槙 I used the Powershell to run it, not more luck with logging, either.
Starting the game from Powershell via java -jar ./libs/Terasology.jar works fine...

I can confirm that it works launching it directly, the exe is the thing that fails.
Running through PowerShell made me aware that it saves data to the saved games directory, so now I have a log to show:
Terasology-init.log

Brief update on the way forward:

I think that I can add a bit of information here regarding why I think that this is happening.

The Java JDK, which is the default option for "AdoptOpenJDK" downloads, defines a different Windows registry path to the JRE.

The Terasology launcher used on Windows searches for the JRE by querying the registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.8\JavaHome
(as found in https://github.com/MovingBlocks/TerasologyJavaLauncher/blob/ed21d8ac0969af364ded8a8ab2fe53795b886789/jredetector_win.cpp#L13).

The JDK path is queried using a different, albeit similar, registry path, which is:
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8\JavaHome

The launcher does not check for Java JDK installations, only for JRE installations. It will not run on systems where the JRE registry key is not defined, unless there is a pre-defined bundled jre dir present (located in the <installDir>/jre folder). Changing the searched registry path from the JRE key to the JDK key in the source code fixed the issue for me.

I have not installed the "AdoptOpenJDK" distribution to test this, however it would appear that their installer also writes to the registry keys mentioned above:
https://github.com/AdoptOpenJDK/openjdk-installer/blob/master/wix/Main.openj9.wxs#L134

So far as I can tell, the JAVA_HOME environment variable is not checked at all, although I have not searched the code in-depth enough to be certain of this.

I have made some changes to make this work on both JRE and JDK Java runtimes. They are located for now in my fork here, until I have time to ensure that the changes are still widely compatible with existing distributions.

I have issued a pull request for the changes I mentioned before, located at https://github.com/MovingBlocks/TerasologyJavaLauncher/pull/1. The changes made should fix this issue, although it will need further testing to be certain.

why has it not been merged yet?

@HybridShivam good question! Most likely because nobody got the time review and test it 馃檲

We've spent some effort on improving the launcher for the regular players by including a JRE with it. Version 4.0.0 just got released.

Was this page helpful?
0 / 5 - 0 ratings