2

To run some applications on a server I require a version 1.7+

I tried to install JDK as shown in link. However, it did could not retrieve the newest package of Java 8. sudo apt-get install openjdk-8-jre

which gave me

Unable to locate package openjdk-8-jdk

with

sudo apt-get install openjdk-7-jre

the installation went ahead but running

java -version

I get: java version "1.6.0_36"

The same package on ubuntu gave me a 1.7... as expected. Does this imply that the Debian repository does not have a proper jdk 1.7, or that I may have had an older installation of Java and need to further configure Java to run at the proper version?

I also took a look at this question however it gave me no satisfactory solution.

2 Answers 2

1

It may be that you have both JRE 6 and JRE 7 installed, and the older version is being preferred. There are two solutions to this:

  1. Remove JRE 6, by running sudo apt-get purge openjdk-6-* (This will remove all parts of Java 6).

  2. Run sudo update-java-alternatives -s java-1.7.0-openjdk-amd64.

0

Run the following:

sudo update-alternative --config java 

Select openjdk8 with enter number of them as default java.

sudo update-alternative --config javac

Select openjdk8 with enter number of them as default javac.

sudo update-alternative --config javaws 

Select openjdk8 with enter number of them as default javaws.

Another way is get jdk (Java Developer's Kit). I think jdk is better than openjdk form site of oracle and follow me for installing them on Linux.

  1. download jdk
  2. extract them
  3. move them in another folder /usr/share/jvm/ or another directory
  4. get permission to run bin software in bin directory in folder of your jdk
  5. using these command for install jdk:

    sudo update-alternative --install "/usr/bin/java" "java" "/yourdirectoryjdk/bin/java" 1
    
    sudo update-alternative --install "/usr/bin/javac" "javac" "/yourdirectoryjdk/bin/javac" 1
    
    sudo update-alternative --install "/usr/bin/javaws" "javaws" "/yourdirectoryjdk/bin/javaws" 1
    
    sudo update-alternative --install "/usr/bin/jps" "jps" "/yourdirectoryjdk/bin/jps" 1
    
  6. then you see your new jdk on list of alternative java program in Linux

    sudo update-alternative --config java 
    
1
  • There is a package called 'java-package' which converts the downloaded jdk tarball from oracle into a proper Debian java package. Just run apt install java-package, then make-jpkg <tarball>, then install the generated .deb file. This will take care of the alternatives thing as well as dealing with other things useful for java in Debian (such as dependencies). Oct 4, 2015 at 11:51

You must log in to answer this question.

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