Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Ubuntu 12.04.2 LTS

What's going on here?

# apt-get install openjdk-7-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  consolekit cryptsetup-bin dbus-x11 dconf-gsettings-backend dconf-service
  gconf-service gconf-service-backend gconf2 gconf2-common gvfs gvfs-common
  gvfs-daemons gvfs-libs libatasmart4 libavahi-glib1 libbonobo2-0
  libbonobo2-common libcairo-gobject2 libcanberra0 libck-connector0
  libcryptsetup4 libdconf0 libfontenc1 libgconf-2-4 libgconf2-4 libgdu0
  libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgnome-keyring-common
  libgnome-keyring0 libgnome2-0 libgnome2-bin libgnome2-common libgnomevfs2-0
  libgnomevfs2-common libgtk-3-0 libgtk-3-bin libgtk-3-common libgudev-1.0-0
  libidl-common libidl0 libllvm3.0 libltdl7 liblvm2app2.2 liborbit2
  libpam-ck-connector libpolkit-agent-1-0 libpolkit-backend-1-0 libsgutils2-2
  libtdb1 libvorbisfile3 libx11-xcb1 libxaw7 libxcb-glx0 libxcb-shape0 libxmu6
  libxpm4 libxv1 libxxf86dga1 libxxf86vm1 mtools openjdk-7-jre policykit-1
  policykit-1-gnome sound-theme-freedesktop udisks x11-utils

Is it possible to install the JDK without half of Gnome and X11? And sound themes? This is a headless (and speakerless) server.

share|improve this question
2  
Does it help if you add the --no-install-recommends option? –  gertvdijk May 30 '13 at 14:53
3  
Why do you need Java Development Kit in a headless server? If you only want to run java applications usually all you need is the Runtime Environment. Try and see if openjdk-7-jre-headless suits your needs. –  Eric Carvalho May 30 '13 at 15:26
10  
@EricCarvalho Here's one use case: a continuous integration server building the Java sources. Building Java software on a headless server isn't that exotic. –  gertvdijk May 30 '13 at 15:30
3  
@gertvdijk Got it. Then I think this is a bug. There should be a openjdk-7-jdk-headless package. –  Eric Carvalho May 30 '13 at 15:34
1  

3 Answers 3

up vote 7 down vote accepted

UPDATED

I personally try to avoid Java because in my opinion it is very clumsy. These instructions are pieced together from various sources, I had to install Java recently and this should work for you.

If your licensing requirements permit, install Oracle Java. Download java from here, you need to chose which one you need based on what you have installed.

JDK x64

wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz

JDK x32

wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-i586.tar.gz

JRE x64

wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-x64.tar.gz

JRE x32

wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-i586.tar.gz

Note that you need a workaround for wget and oracle to play nice together.

Create a directory where your Java will live:

sudo mkdir -p /usr/lib/jvm

Move the downloaded Java:

sudo mv jdk-7u51-linux-x64.tar.gz /usr/lib/jvm

Extract Java:

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

Tell Ubuntu that Java exists:

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_51/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_51/bin/java 1
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.7.0_51/bin/javac
sudo update-alternatives --set java /usr/lib/jvm/jdk1.7.0_51/bin/java

Add java path to your system profile, so that the machine knows where the Java binaries are:

sudo nano /etc/profile

At the end of the file add this:

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_51
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Save and reboot.

Test your Java installation:

java -version
share|improve this answer
1  
This worked for me. The only change I made was to add a symlink from the current jdk directory /usr/lib/jvm/jdk1.7.0_45 to the generic location: /usr/lib/jvm/java-7-oracle This way one doesn't have to update the path in /etc/profile (and in possible other application locations) every time the JDK is updated. Also many programs (e.g. elasticsearch) look for java at /usr/liv/jvm/java-7-oracle as one of the default locations. –  Ville Mar 22 at 6:51

Very old stuff, but if some one is lookig for this yet, just install openjdk-7-jre-headless or openjdk-6-jre-headless

share|improve this answer
    
The question is asking specifically about version 7. –  David Foerster Dec 2 at 0:51
    
jre != jdk there's no jdk-headless –  Dr.Haribo Dec 3 at 8:59

I think this is not a good idea to skip any dependency when installing from source. You can't skip this all time. When you update dependency using apt-get it will be check there also.

share|improve this answer
2  
"when installing from source" OP isn't installing from source. –  gertvdijk May 30 '13 at 15:29

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.