Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 1 down vote accepted

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

http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp

Get the server JRE or JDK for instance:

jdk-7u51-linux-x64.tar.gz

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 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

 
discard

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.