0

I am trying to install Java 7. I tested my Java version first, please see the below code

ubuadmin@ubuserver3:~/JavaJars/HelloWordGPU$ java -version
java version "1.6.0_30"
OpenJDK Runtime Environment (IcedTea6 1.13.1) (6b30-1.13.1-1ubuntu2~0.12.04.1)
OpenJDK Client VM (build 23.25-b01, mixed mode, sharing)

I tried uninstalling this first, using below command:

sudo apt-get remove openjdk-6-jdk

It gave me the following result.

ubuadmin@ubuserver3:~/JavaJars/HelloWordGPU$ sudo apt-get remove openjdk-6-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package openjdk-6-jdk is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
ubuadmin@ubuserver3:~/JavaJars/HelloWordGPU$

I also tried using sudo apt-get remove default-jdk but same.

So how can I install Java 7?

halfer
  • 19,824
  • 17
  • 99
  • 186
PeakGen
  • 21,894
  • 86
  • 261
  • 463
  • I have 2 close votes here, without even quoting why! – PeakGen Mar 12 '14 at 04:46
  • @ElliottFrisch: I tried google. I visited http://stackoverflow.com/questions/20690143/java-unsupported-major-minor-version-51-0, http://askubuntu.com/questions/139702/completely-uninstall-and-reinstall-openjdk, and http://askubuntu.com/questions/84483/how-to-completely-uninstall-java. That is why I came here. – PeakGen Mar 12 '14 at 04:47

2 Answers2

1

From the directions posted here,

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

Then you can use update-java-alternatives,

sudo update-java-alternatives -l
sudo update-java-alternatives -s <The correct Java 7 JDK>
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
1

You could install openjdk-7-jdk directly by

apt-get install openjdk-7-jdk

After that, you could use update-java-alternatives to set it as your default Java

update-java-alternatives -l
update-java-alternatives -s <jname>
Lee Duhem
  • 14,695
  • 3
  • 29
  • 47
  • I really don't understand what is wrong here. This is the output `Reading package lists... Done` `Building dependency tree` `Reading state information... Done` `openjdk-7-jdk is already the newest version.` `0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.` `root@ubuserver3:/home/ubuadmin/JavaJars/HelloWordGPU# java -version` `java version "1.6.0_30"` `OpenJDK Runtime Environment (IcedTea6 1.13.1) (6b30-1.13.1-`1ubuntu2~0.12.04.1)` `OpenJDK Client VM (build 23.25-b01, mixed mode, sharing)` `root@ubuserver3:/home/ubuadmin/JavaJars/HelloWordGPU#` – PeakGen Mar 12 '14 at 05:22
  • @GloryOfSuccess It looks like you already installed `openjdk-7-jdk`. You could use `update-java-alternatives` to set it as your default java, please refer to the answer given by Elliott Frisch. – Lee Duhem Mar 12 '14 at 05:28
  • what does it ask for the next parameter? I am not a Linux person even I am doing this. – PeakGen Mar 12 '14 at 05:31
  • @GloryOfSuccess First part of the `-l` output. – Lee Duhem Mar 12 '14 at 05:36