LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 11-07-2015, 10:49 AM   #1
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Rep: Reputation: 47
java versions problem


On a recent update of my Debian Stable system, which is otherwise working very well, I found following warning:

Quote:
Setting up openjdk-7-jre-headless:i386 (7u85-2.6.1-6+deb8u1) ...
Installing new version of config file /etc/java-7-openjdk/security/java.security ...
update-binfmts: warning: current package is openjdk-7, but binary format already installed by openjdk-6
Setting up openjdk-7-jre:i386 (7u85-2.6.1-6+deb8u1) ...
I have following installed on my system:

Code:
default-jre             2:1.7-52        2:1.7-52        2:1.7-52        install
default-jre-headless    2:1.7-52        2:1.7-52        2:1.7-52        install
gcj-4.6-jre-headless    4.6.3-1         N/A             N/A             install
gcj-4.6-jre-lib         4.6.3-1         N/A             N/A             install
gcj-4.7-jre             4.7.2-3         N/A             N/A             install
gcj-4.7-jre-headless    4.7.2-3         N/A             N/A             install
gcj-4.7-jre-lib         4.7.2-3         N/A             N/A             install
gcj-4.9-jre             4.9.2-10        4.9.2-10        4.9.2-10        install
gcj-4.9-jre-headless    4.9.2-10        4.9.2-10        4.9.2-10        install
gcj-4.9-jre-lib         4.9.2-10        4.9.2-10        4.9.2-10        install
gcj-jre                 4:4.9.2-2       4:4.9.2-2       4:4.9.2-2       install
gcj-jre-headless        4:4.9.2-2       4:4.9.2-2       4:4.9.2-2       install
openjdk-6-jre-lib       6b34-1.13.6-1~deb7u1    N/A             N/A             install
It seems I have multiple versions installed. I think default-jre-headless points to openjdk-7-jre-headless.
How can I optimize so that I can run java programs smoothly? Thanks for your help.
 
Old 11-07-2015, 11:19 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
i'm sorry i don't have debian specific help, but on archlinux this helped:
https://wiki.archlinux.org/index.php...ng_between_JVM

here's the archlinux-java script:
Code:
#! /bin/bash

# Arch Linux helper script to set/unset/check/fix the enabled Java environment
# This program may be freely redistributed under the terms of the GNU General Public License
#
# Author: Guillaume ALAUX <guillaume@archlinux.org>

JVM_DIR=/usr/lib/jvm
DEFAULT_NAME=default
DEFAULT_PATH=${JVM_DIR}/${DEFAULT_NAME}
DEFAULT_NAME_JRE=default-runtime
DEFAULT_PATH_JRE=${JVM_DIR}/${DEFAULT_NAME_JRE}


# Utility functions

check_root() {
  if [ $(id -u) -ne 0 ]; then
    echo 'This script must be run as root'
    exit 1
  fi
}

# $1: parameter count given to this script for this option
# $2: expected parameter count for this option
check_param_count() {
  if [ $1 -ne $2 ]; then
    echo 'Wrong parameter count'
    exit 2
  fi
}

# Second level functions

get_default_java() {
  path=$(readlink -e ${DEFAULT_PATH})
  if [ "x${path}" != "x/dev/null" ]; then
    echo ${path/${JVM_DIR}\/}
  else
    echo ""
  fi
}

get_installed_javas() {
  if [ -d ${JVM_DIR} ]; then
    for dir in $(find ${JVM_DIR} -mindepth 1 -maxdepth 1 -type d | sort); do
      if [ -x ${dir}/bin/javac ]; then
        javas+=(${dir/${JVM_DIR}\/})
      else
        if [ -x ${dir}/jre/bin/java ]; then
        javas+=(${dir/${JVM_DIR}\/}/jre)
        fi
      fi
    done
  fi
  echo ${javas[@]}
}

# $1: Java environment name to test
is_java_valid() {
  test "x$1" != "x${DEFAULT_NAME}" && test -x ${JVM_DIR}/$1/bin/java
}

# $1: Java environment name to set as default
set_default_link_to() {
  new_default=$1
  unlink ${DEFAULT_PATH} 2>/dev/null
  ln -sf ${new_default} ${DEFAULT_PATH}

  unlink ${DEFAULT_PATH_JRE} 2>/dev/null
  if [[ ${new_default} == */jre ]]; then
    ln -sf ${new_default} ${DEFAULT_PATH_JRE}
  else
    ln -sf ${new_default}/jre ${DEFAULT_PATH_JRE}
  fi
}

unset_default_link() {
  unlink ${DEFAULT_PATH} 2>/dev/null
  unlink ${DEFAULT_PATH_JRE} 2>/dev/null
}

# First level functions

do_status() {
  installed_java=($(get_installed_javas))
  if [ ${#installed_java[@]} -eq 0 ]; then
    echo 'No compatible Java environment installed'
  else
    default_java=$(get_default_java)
    echo 'Available Java environments:'
    for java in ${installed_java[@]}; do
      if [ "${java}/jre" = "${default_java}" ]; then
        echo -e "  ${java} (${java}/jre default)"
      elif [ ${java} = "${default_java}" ]; then
        echo -e "  ${java} (default)"
      else
        echo "  ${java}"
      fi
    done
    if [ -z ${default_java} ]; then
      echo "No Java environment set as default"
    fi
  fi
}

do_get() {
  get_default_java
}

# $1: Java environment name to set as default
do_set() {
  if ! is_java_valid $1; then
    echo "'${JVM_DIR}/$1' is not a valid Java environment path"
    exit 1
  fi
  default=$(get_default_java)
  if [ "x$1" != "x${default}" ] || ! is_java_valid ${default}; then
    unset_default_link
    set_default_link_to $1
  fi

  #parent_dir=$(dirname $1)
  #if is_java_valid ${parent_dir}; then
  #  echo "Warning: '${parent_dir}' looks like a valid JDK whereas '$1' is set as default"
  #  echo "Fix this with 'archlinux-java set ${parent_dir}'"
  #fi
}

# $1: Java environment name to unset
do_unset() {
  unset_default_link
}

do_fix() {
  default=$(get_default_java)
  if is_java_valid ${default}; then
    if is_java_valid $(dirname ${default}); then
      unset_default_link
      set_default_link_to $(dirname ${default})
    fi
  else
    prev=$(readlink ${DEFAULT_PATH})
    unset_default_link
    prev_fix=("${prev/\/jre}" "${prev}/jre")
    openjdk7=('java-7-openjdk' 'java-7-openjdk/jre')
    to_check=(${prev_fix[@]} ${openjdk7[@]} $(get_installed_javas))
    for java in ${to_check[@]}; do
      if ! is_java_valid $(get_default_java) && is_java_valid ${java}; then
        set_default_link_to ${java}
      fi
    done
  fi
  if ! is_java_valid $(get_default_java); then
    echo 'No valid Java environment found'
  fi
}

usage() {
  echo "$(basename $0) <COMMAND>"
  echo -e "\nCOMMAND:"
  echo -e '\tstatus\t\tList installed Java environments and enabled one'
  echo -e '\tget\t\tReturn the short name of the Java environment set as default'
  echo -e '\tset <JAVA_ENV>\tForce <JAVA_ENV> as default'
  echo -e '\tunset\t\tUnset current default Java environment'
  echo -e '\tfix\t\tFix an invalid/broken default Java environment configuration'
}

## Main
case $1 in
  'status') do_status;;
  'get')    do_get;;
  'set')    check_root; check_param_count $# 2; do_set $2;;
  'unset')  check_root; do_unset;;
  'fix')    check_root; do_fix;;
  'help' | '--help' | '-h' | '') usage;;
  *)           echo "$(basename $0): unknown option '$@'"; exit 1;;
esac
maybe you can glean something useful from it.
 
Old 11-07-2015, 11:29 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The gcc java (gcj-*) is present because some packages depends on it.


Selecting the java version you want to use :
$ sudo alternatives --config java : EDIT
EDIT : # update-alternatives --config java


-

Last edited by knudfl; 11-07-2015 at 11:19 PM.
 
Old 11-07-2015, 08:23 PM   #4
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Original Poster
Rep: Reputation: 47
Using script program by @ondoho I found following:

Available Java environments:
java-1.5.0-gcj-4.6/jre
java-1.5.0-gcj-4.7/jre
java-1.5.0-gcj-4.9-i386
java-6-openjdk-i386/jre
java-7-openjdk-i386/jre
No Java environment set as default

'alternatives' is not installed in my Debian Stable. I checked repository- there is galternatives and kalternatives. I installed kalternatives which gave a GUI program but not 'alternatives' command. The GUI program also listed all above environments, in same order as above and they are in increasing order of priority. The java-7-openjdk has highest priority and is also checked on GUI program.

How can I just keep only gcj-4.9 and java-7-openjdk? Can I just uninstall others?
 
Old 11-07-2015, 11:19 PM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
These "alternatives" files are installed with the package 'dpkg' :
( You can't have a Debian OS with no dpkg )

/etc/alternatives/README ( Please read )
/usr/bin/update-alternatives
/usr/sbin/update-alternatives
https://packages.debian.org/jessie/amd64/dpkg/filelist

The right "java select" command is : # update-alternatives --config java
Sorry.


-

Last edited by knudfl; 11-07-2015 at 11:20 PM.
 
Old 11-08-2015, 02:28 AM   #6
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Original Poster
Rep: Reputation: 47
Will update-alternatives set the default only or remove others? I want to keep latest gcj and latest openjdk with openjdk as default. Can I use apt-get purge command for others?
 
Old 11-08-2015, 03:09 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
update-alternatives will not remove software.
you can try to purge the other versions, but it's possible that some other software still depends on it and complains in the process. so unless you just blindly press Enter on everything, you can try that purge.

since this is java, it is also possible that some other software that is not installed through debian's packet management depends on some particular version.
in that case you wouldn't get a warning.
but you should know if you use software like that.
 
1 members found this post helpful.
Old 11-08-2015, 06:24 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
See post #5 : /etc/alternatives/README :

"Please read the update-alternatives(8) man page for information on this
directory and its contents."

$ man 8 update-alternatives




-

Last edited by knudfl; 11-08-2015 at 06:26 AM.
 
Old 11-08-2015, 07:52 AM   #9
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Original Poster
Rep: Reputation: 47
I purged all older versions and now following shows up on my system:

Code:
$ update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      auto mode
  1            /usr/bin/gij-4.9                                1049      manual mode
  2            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      manual mode

Press enter to keep the current choice[*], or type selection number:
I think, the latest version of gcj seem to have changed to gij.

Currently purging older versions has not caused any problems but I will know in the future.

Very related to this is icedtea and I have following on my system:

Code:
icedtea-netx-common     1.5-2+deb8u1    1.5-2+deb8u1    1.5-2+deb8u1    install
icedtea-plugin          1.5-2+deb8u1    1.5-2+deb8u1    1.5-2+deb8u1    install
icedtea-7-jre-jamvm     N/A             7u79-2.5.5-1~deb8u1     7u85-2.6.1-6+deb8u1
I do not have third package in above list installed. Do I need it (icedtea-7-jre-jamvm)?

Last edited by rng; 11-08-2015 at 07:59 AM.
 
Old 11-08-2015, 09:03 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #9.

The "open source" java is { icedtea-* + java-7-openjdk }.

`icedtea-*' cannot be removed, if you want to keep java-7-openjdk.
 
Old 11-08-2015, 09:20 AM   #11
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Original Poster
Rep: Reputation: 47
What is icedtea-7-jre-jamvm and when is it needed?
 
Old 11-08-2015, 09:40 AM   #12
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
What is icedtea-7-jre-jamvm
https://www.google.com/webhp?hl=all&...ea-7-jre-jamvm
 
Old 11-07-2016, 10:15 PM   #13
Rocdufer
LQ Newbie
 
Registered: May 2012
Location: Mexico City
Distribution: Ubuntu and Debian
Posts: 7

Rep: Reputation: Disabled
Solve the first issue in this thread

Somehow this thread became "threaded". The original issue was the warning

update-binfmts: warning: current package is openjdk-7, but binary format already installed by openjdk-6.

That binary format can be removed by the very same notifier package by issuing the command line:

sudo update-binfmts --package openjdk-6 --remove jar /usr/bin/jexec

as stated in a Ğaskubuntuğ question 259096 by Raul. I test it and worked.

Last edited by Rocdufer; 11-07-2016 at 10:18 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
To install java in solaris sparcv9 and removing the preinstalled java versions saurabh593 Solaris / OpenSolaris 6 06-14-2012 01:43 PM
Two versions of Java and two browsers TheOracle Linux - Software 3 03-23-2007 10:19 AM
How to switch java versions... markw8500 Programming 3 09-24-2006 06:54 PM
Using two versions of Java UmneyDurak Linux - Software 1 10-02-2005 12:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration