How To: Install the official Oracle JRE/JDK in Linux
r3dux | September 26, 2012Installing the official Sun/Oracle Java implementations used to be as easy as installing sun-java6-* and uninstalling all the OpenJDK and IcedTea (Java plugins based on OpenJDK) packages you could find – but you can’t get the offical “Sun” packages anymore, instead you have to go get the binaries from Oracle (who bought Sun Microsystems). You can take a swiz at the possible Java implementations here if you like.
Anyways, to get and install the official JRE or JDK (I’ll assume that most people aren’t going to be developing in Java so only want the Runtime Environment and not the full Development Kit):
- Head on over to: http://www.oracle.com/technetwork/java/javase/downloads/index.html and download tar.gz version of the latest JRE, which at the time of writing is 1.7 update 7 (i.e. 1.7.0_07, the Linux 64-bit version of which is called jre-7u7-linux-x64.tar.gz),
- Extract the downloaded archive through any way you see fit. I’ll assume you downloaded it to your Downloads folder and extracted it there for the following commands,
- Create a new folder for it wherever your distro likes to put Java installs, for example:
sudo mkdir /usr/lib/jvm/jre1.7.0_07
- Move your extracted JRE to that location using:
sudo mv ~/Downloads/jre7_u7/* /usr/lib/jvm/jre1.7.0_07/"
- Update your alternatives to prefer the new version of java by running (one line at a time):
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.7.0_07/bin/java" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.7.0_07/bin/javaws" 1
If you’re installing the JDK you’ll prolly want to set the javac (Java Compiler) binary to the new version too using:
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jre1.7.0_07/bin/javac" 1
The number at the end of the line is the priority of this binary out of any other java/javac/javaws binaries alternatives knows about, and goes from 1 (most important – try to use first) to 100 (least important – use only as a last resort)
- If you want to set, or make sure the update-alternatives commands took, you can also run (again, one line at a time):
sudo update-alternatives --config java sudo update-alternatives --config javaws sudo update-alternatives --config javac <-- only if you installed the JDK
- Finally, to check it all really took, issue:
java -versionand you should see some output showing that the newest version of Java is in effect, like this:
java version "1.7.0_07" Java(TM) SE Runtime Environment (build 1.7.0_07-b10) Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
Done & dusted.
Feb 2013 Update: More recent versions of Wine are now available in the standard LMDE repositories, so skip all the headache below and just install Wine with a s swift sudo apt-get install wine and you’re done!












