Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't have java installed on a Ubuntu virtual machine (just server, no X11):

bash: java: command not found

I want to install a minimal version to run some scripts. When I issue:

sudo apt-get install openjdk-7-jre

It tries to install 109 packages, and some of them are x11-common x11-utils sound-theme-freedesktop

I want to avoid having to install such a beast with such a lot of unneeded stuff. Is there a way to install a more minimal java that will suit me to run console apps.

share|improve this question
up vote 1 down vote accepted

Try getting the jvm in .tar.gz format from oracle:

Get the server JRE or JDK for instance:


Untar it into /opt:

java -> jdk1.7.0_51/

Make a symlink to /opt/java

ln -s /opt/jdk1.7.0_51 /opt/java

Set JAVA_HOME=/opt/java

Put /opt/java/bin somewhere on your path.

You should then be able to run which java and see it come from /opt/java` and finallyjava -version`` should report the version of java you just downloaded.

This keeps everything outside of the operating system's package management system and dependencies, which is why ubuntu is trying to load all those extra packages. It also means that you don't have to worry about breaking your java when you update your Ubuntu. You just need to make sure you keep java reasonable upto date yourself.

share|improve this answer
Of course, that package itself is nearly as big. – Michael Hampton Feb 3 '14 at 15:03

The following will get the java executable installed on Ubuntu (13.10) with minimal dependencies:

apt-get install openjdk-7-jre-headless
share|improve this answer

Your Answer


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.