Installing a Java application

I’m trying to install BGBlitz backgammon application from this link. However, I get the following error as shown in the screenshot:

To get around that error, I make the referenced bgblitz.sh file executable and try to execute it from the terminal. When I do, the following error is printed:

JAVA = ./jre/bin/java
JVM_OPTS = -Xmx832m --enable-preview --add-modules jdk.incubator.vector -Dlogback.configurationFile=system/logback.xml --add-exports ALL-UNNAMED/bgblitz.chat.Chat=java.rmi --add-exports ALL-UNNAMED/bgblitz.play.DiceMan=java.rmi --add-exports ALL-UNNAMED/bgblitz.play.RemotePlayer=java.rmi
HOME = .
Could not start dynamically linked executable: ./jre/bin/java
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:






Could not start dynamically linked executable: ./jre/bin/java
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld

How can I get this app to work?

1 Like

This app bundles it’s own Java Runtime Environment (JRE), which is not compiled for running on NixOS and thus fails. Normally, one would recompile the app including the custom JRE for NixOS.

You get more info and possible solutions, if you follow the link at the end of the error message.

I previously followed the link in the error. To be honest, I couldn’t make any sense of what exactly is to be done or how to actually do it. A bit of guidance on the easiest solution would be appreciated.

If you want to write no Nix whatsoever and just run a random binary from the internet on your NixOS machine with zero setup, I recommend distrobox.

After that, we’re talking about various ways you can write, in Nix, a package expression for this application to put in your configuration.nix file. Of these, the easiest with which to get started is probably autoPatchElfHook: read and adapt this example. You will need to determine the list of buildInputs for your application via trial and error, probably.

1 Like

the alternative for this case would be to install java via nix and just delete the downloaded jdk symlink to the nixos one. this will work till your next rebuild-switch but for such temporary stuff its also an easy alternative

1 Like

I’m going to follow the example and see how it goes. Will report on my progress. Thanks.