I had been experiencing issues getting java to run on a new server. While trying to check whether java was working I was repeatedly getting the following error:

Tried increasing memory allocated to the java process, tried a lot of things mentioned by people online but nothing helped. The server had enough ram, 24GB free.

Turn’s out I had to disable MPROTECT as I was on a hardened kernel. To do this first run:

To find out where java is located run:

Then:

and finally to disable MPROTECT:

This now allows java to run fine, issuing the java -version command at shell no longer throws an error instead shows the version of Java installed which is what you should actually be seeing.

 

In case you want to turn MPROTECT back on issue the following: