I've installed JDK-8 on my VPS with the command:
sudo apt-get install openjdk-8-jdk
But I just realized I don't really need JDK and JRE is enough for me since I develope my projects on my laptop in intellij and test them and then I just need to run the final jar file on my server. So what is the best way to keep JRE and remove the rest of JDK.