Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I tried to install the current oracle jre on a VM running NixOS.

Now the following happens:

[michas@cc:~]$ tar xvzf jre-7u40-linux-x64.tar.gz |grep bin/java
jre1.7.0_40/bin/javaws
jre1.7.0_40/bin/java_vm
jre1.7.0_40/bin/java

[michas@cc:~]$ ls -l ./jre1.7.0_40/bin/java
-rwxr-xr-x 1 michas nogroup 7750 Aug 27 09:17 ./jre1.7.0_40/bin/java

[michas@cc:~]$ ./jre1.7.0_40/bin/java
bash: ./jre1.7.0_40/bin/java: No such file or directory

WTF? The named file is obviously there. What is going on?

Trying to analyse further:

[michas@cc:~]$ strace ./jre1.7.0_40/bin/java
execve("./jre1.7.0_40/bin/java", ["./jre1.7.0_40/bin/java"], [/* 53 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1)                           = ?
+++ exited with 1 +++

[michas@cc:~]$ strace ./jre1.7.0_40/bin/jav
strace: Can't stat './jre1.7.0_40/bin/jav': No such file or directory

Ok, the output of a really missing file looks different.

[michas@cc:~]$ file ./jre1.7.0_40/bin/java
./jre1.7.0_40/bin/java: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, BuildID[sha1]=a558f547fe0b95fdc6a109cb7d9692d6d7969794, not stripped

[michas@cc:~]$ file ~/t
/home/michas/t: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped

The latter is a tiny self compiled binary running without problems. Both look very similar. Hence format the binary itself seems to be fine.

[michas@cc:~]$ ldd ./jre1.7.0_40/bin/java
/run/current-system/sw/bin/ldd: line 116: ./jre1.7.0_40/bin/java: No such file or directory

Seems like there is a problem regarding the needed shared libraries.

What is going on and how can I fix it?

share|improve this question
add comment

2 Answers

You can't usually run binary files in NixOS, they will either need some environment variables set or to be patched with patchElf. I assume you can install and run java using the nix package manager. You can probably also create a suitable environment to run it using myEnvFun.

share|improve this answer
add comment

It looks like nixos has a package for oracle jre7.

If you want to make a custom nix expression to install jre or jdk then it might be a good idea to look at the existing nix expression for jdk7/jre7.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.