1

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.

2 Answers 2

1

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.

2
  • Of course, that package itself is nearly as big. Feb 3, 2014 at 15:03
  • this is the wrong answer, please refer to the answer below lol
    – Dave Ankin
    Mar 27, 2021 at 20:47
10

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

apt-get install openjdk-7-jre-headless
1
  • still work with ubuntu 18.04 Jun 5, 2019 at 21:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .