Skip to content

Instantly share code, notes, and snippets.

@bbarker
Created May 31, 2019 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbarker/366940b3490acef8120ea2e77ce81dc1 to your computer and use it in GitHub Desktop.
Save bbarker/366940b3490acef8120ea2e77ce81dc1 to your computer and use it in GitHub Desktop.
Patch matlab java
echo "Patching java... ($MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java)"
chmod u+rw "$MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java"
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "$libPath:$(patchelf --print-rpath $MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java)"\
--force-rpath "$MATLAB_PATH/sys/java/jre/glnxa64/jre/bin/java"
@bbarker
Copy link
Author

bbarker commented May 31, 2019

Still get this error:

[nix-shell:~]$ /opt/MATLAB/R2017a/sys/java/jre/glnxa64/jre/bin/java
bash: /opt/MATLAB/R2017a/sys/java/jre/glnxa64/jre/bin/java: cannot execute binary file: Exec format error

readelf seems to indicate it is 64bit, which would match the matlab install type:

[nix-shell:~]$ readelf -h /opt/MATLAB/R2017a/sys/java/jre/glnxa64/jre/bin/java
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x400520
  Start of program headers:          64 (bytes into file)
  Start of section headers:          3263792 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         87
  Size of section headers:           64 (bytes)
  Number of section headers:         34
  Section header string table index: 31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment