Problem
If you install Oracle JDK and you are using binfmt misc.
when you run an executable jar file:
invalid file (bad magic number): Exec format error
Diagnosis
- /proc/sys/fs/binfmt_misc/jexec
check if you have
/proc/sys/fs/binfmt_misc/jexec << this is the offending spec
normally you would also have /proc/sys/fs/binfmt_misc/ExecutableJAR if binfmt_misc is installed
- /etc/]init.d/jexec
check if you can find
/etc/]init.d/jexec
and that this is sym link to the actual jexec binary
e.g./etc/]init.d/jexec -> /usr/java/jdk1.8.0_212-amd64/.java/init.d/jexec
Fix
- remove the symlink /etc/]init.d/jexec
- install binfmt_misc and java binfmt_misc if you still want executable jar functionality
Bug
Oracle’s jexec for some reason is broken, i think they used to work and runs executable jar file. but the recent release i installed doesn’t do that anymore