12

I have been trying to get Java for the past day now. I followed several tutorials but I keep getting the same error. After I put in tar -xvf jre-7u4-linux-i586.tar.gz it says Cannot open: No such file or directory tar: Error is not recoverable: exiting now

I have a 64 bit system so I doubt that's the problem. The JDK installed perfectly, but I'm lost as to why the JRE wont work...

4
  • 3
    You say that you have a 64-bit system, but the package says 1586. Make sure you have the right version. May 13, 2012 at 3:53
  • If you install the JDK, that typically includes the JRE as well.
    – ish
    May 13, 2012 at 5:09
  • 1
    Did you actually download that file? May 16, 2012 at 13:14
  • And where do you write it? It needs to be in a terminal window. Jun 26, 2012 at 12:21

8 Answers 8

19

If OpenJDK isn't preferred, you can install the Oracle version from a ppa (which is a lot easier than manual installation, and you should also receive updates automatically). Adding via ppa also ensures that you are using the correct architecture (32 vs 64 bit).

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Source: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

3
  • "add-apt-repository" command doesn't exist o_O
    – knocte
    Sep 21, 2012 at 11:14
  • 1
    knocte - had that same issue. RTFG says you need to install python-software-properties or add it to /etc/apt/sources.list manually.
    – lonstar
    Sep 22, 2012 at 14:01
  • The best way for now.
    – Apache
    Apr 25, 2013 at 8:29
5

The simplest way to get Java installed with Ubuntu 12.04 is to run

sudo apt-get install default-jdk

Do not mess with downloading any files - just use the package manager.

3
  • 1
    That'll give you OpenJDK, which isn't compatible with ANYTHING. Aug 31, 2012 at 15:04
  • @fiXedd Either you don't know what you are talking about and then perhaps you should not comment, or you do know what you are talking about, and then you should know better. Aug 31, 2012 at 17:51
  • I should know better :) Seriously though... quite a few things won't work with OpenJDK (or are subtly buggy). Sep 5, 2012 at 20:05
4

This set of instructions is for 64bit Java installation

Download Java to the Downloads folder

1 - Open Terminal, copy & paste the following commands

sudo mkdir -p -v /opt/java/64

Press Enter

cd Downloads && tar xvzf ~/Downloads/jre-7u4-linux-x64.tar.gz

Press Enter

sudo mv -v ~/Downloads/jre1.7.0_04 /opt/java/64

Press Enter

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.7.0_04/bin/java" 1

Press Enter

sudo update-alternatives --set java /opt/java/64/jre1.7.0_04/bin/java

Press Enter

mkdir -v ~/.mozilla/plugins 

Press Enter

Now remove the IcedTea plugin, if it has been installed. If it's not there to begin with, you'll see a notification of that.

sudo apt-get remove icedtea6-plugin

Press Enter

Remove a former version of the Java plugin (may or may not be present, run the command just to make sure). If it's not there to begin with, you'll see a notification of that.

rm -v ~/.mozilla/plugins/libnpjp2.so

Press Enter

ln -s /opt/java/64/jre1.7.0_04/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

Press Enter

These instructions were copied verbatim from the Easy Linux Tips Project

I have used these instructions myself and can verify that they do work.

Easy Linux Tips - Installing Oracle Java

4
  • This is good but OP states they are using a 64 bit system. Can you update your answer to also include the x64 instructions?
    – amc
    May 16, 2012 at 12:56
  • 1
    Or you can install it using PPA sudo add-apt-repository ppa:webupd8team/java and let the installer handle all the hassle mentioned in the above answer. But its better to be aware with "long-cut" before you opt-in for "short-cut" ;-)
    – Kushal
    May 16, 2012 at 13:12
  • @Kush I was just adding that ppa info as an answer
    – amc
    May 16, 2012 at 13:21
  • @amc: The answer I commented fulfills the need anyway, PPA is just easier way to work out the same :-)
    – Kushal
    May 16, 2012 at 13:24
3

Open Software Center and type jre there.

java

1
  • I don't have sure about version 7, but in 6, JRE from OpenJDK and Sun are different, for example, the VPN application I use in my company doesn't work with OpenJDK, just with JRE from Sun.
    – Pipe
    May 16, 2012 at 13:04
3

I had the same problem with a friends machine, all i did was to install the openjdk, this can be done using the below command

sudo apt-get install openjdk-7-oracle

The above command work in 12.04, but to previous version you either add some ppa, or just run the below command

sudo apt-get install openjdk-6-jdk

It worked for me and my friend.

Hope that helped.

2

For 64 bit i've tested and woked on before.

Those are the steps i did before:

Download the sun jre 7 tar file from here

Extract the tar file:

tar -xvzf jre-7u4-linux-x64.tar.gz

Move extracted folder to this location:

sudo mv jre1.7.0_04 /usr/lib/jvm/

Install new java source in system:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0_04/bin/java 1

Choose default java:

sudo update-alternatives --config java

java version test:

java -version

Verify the symlinks all point to the new java location:

ls -la /etc/alternatives/java*

For 32bit architecture see this link

2

This guy and myself need Sun JAVA specifically as many things do not run on openJDK thus people will ask about Sun Java, openJDK is not useless just it is behind Sun Java as Sun Java will always be a little ahead as it has more support.

So for the people that need SUN JAVA (Oracle) here is what I did: I found these commands got me up and running.

I feel sorry for the people that just want the solution but its really getting bad that people give a solution without reading or knowing what they are talking about.

I had the same problem and found that 3 sites fixed my issue and I hope this helps.

I installed ubuntu 12.04 Server 64bit. Hardware specs
Intel Xeon E5-2620 on Intel S2600CP2
Host OS Vmware ESXI 5.0
Guest ubuntu 12.04 Server 64bit

And I logged in. I typed the following commands to get Java 7 64bit installed.

sudo apt-get install python-software-properties << i believe this installs the apt-get-repository scripts.

sudo apt-get update <<< updates the software list

sudo apt-get upgrade <<< updates and installs software from list.

sudo apt-get dist-upgrade <<< upgrades version of ubuntu server example 11.05 to 12.01

sudo reboot <<< reboot is a must.

sudo add-apt-repository ppa:webupd8team/java <<< adds repository for Oracle Java

sudo apt-get update <<< refresh list

sudo apt-get install oracle-java7-installer << install Java

java -version <<< checks java version installed.

You should get JAVA(TM) 64bit version

I hope this helps.

1

OpenJDK Java is a wise option, better though. But if you still insist on Oracle Java, then please download jre-7u4-linux-x64.tar.gz file from their site and do the same operations . It will do the job.

You must log in to answer this question.

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