Update-Alternatives: Warning: /Etc/Alternatives/Java Is Dangling

update-alternatives: warning: /etc/alternatives/java is dangling

Assuming you installed the OpenJDK6 with:

sudo apt-get install openjdk-6-jdk

In Ubuntu 64 bit, make sure the paths are valid for your installation (change if using 32bit version):

/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java

/usr/lib/jvm/java-6-openjdk-amd64/bin/javac

Setup update-alternatives:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-6-openjdk-amd64/bin/javac" 1

sudo update-alternatives --set java /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-6-openjdk-amd64/bin/javac

Alternatively, make sure the correct version is checked for both Java and compiler:

sudo update-alternatives --config java
sudo update-alternatives --config javac

List the installed Java alternatives with:

sudo update-alternatives --list java
sudo update-alternatives --list javac

Error thrown in update-alternatives

if you need to install java in Ubuntu, you can try using following command and you will get oracle-java-installer in your synaptic package manager, click it and install it.

sudo add-apt-repository ppa:webupd8team/java

Else try following steps

 $ wget http://download.oracle.com/otn-pub/java/jdk/6u34-b04/jre-6u34-linux-i586.bin
$ chmod u+x jre-6u34-linux-i586.bin
$ ./jre-6u34-linux-i586.bin
$ sudo mkdir -p /usr/lib/jvm
$ sudo mv jre1.6.0_34 /usr/lib/jvm/
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_34/bin/java" 1
$ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jre1.6.0_34/lib/i386/libnpjp2.so" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_34/bin/javaws" 1

update-alternatives : update java path

According to the man page there is no parameter for update-alternatives to change an entry. So you would have to remove your entry 2 with --remove and --install it again. Then you might have to --config the command again to point to the correct directory.

Alternatively, you can manually change the entry in /var/lib/dpkg/alternatives/java directly.

Elasticsearch installation

first install your java (version 8+) and set $JAVA_HOME variable or download java. use update-alternative to set default java.

update-alternatives: warning: /etc/alternatives/java is dangling

then, install elasticsearch from rpm file and config /etc/elasticsearch/elasticsearch.yml.

https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html

now, you can start elasticseach service by executing :

service elasticsearch start

Unable to downgrade java version from 1.8 to 1.7 in ubuntu

Bitnami developer here. Please find below the steps required to install Java 7 JDK on your system and modify the Bitnami environment for changes to take effect. As an extra step before starting to modify your system, I recommend you to create a server backup.

  • Install Java 7 JDK on your system by running the commands below. It should be installed at /usr/lib/jvm/java-7-openjdk-amd64

    sudo apt-get update
    sudo apt-get install openjdk-7-jdk
  • Create a backup of the files that you need to modify

    cp /home/bitnami/.bashrc /home/bitnami/.bashrc.bck
    sudo cp /opt/bitnami/scripts/setenv.sh /opt/bitnami/scripts/setenv.sh.bck
    sudo cp /opt/bitnami/apache-tomcat/scripts/ctl.sh /opt/bitnami/apache-tomcat/scripts/ctl.sh.bck
    sudo cp /opt/bitnami/apache-tomcat/bin/setenv.sh /opt/bitnami/apache-tomcat/bin/setenv.sh.bck
  • Set PATH and LD_LIBRARY_PATH environment variables to point to the Java 7 installation directory adding the lines below at the end of the /opt/bitnami/scripts/setenv.sh file

    # Set PATH and LD_LIBRARY_PATH for Java 7
    PATH="/usr/lib/jvm/java-7-openjdk-amd64/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/java/bin:/opt/bitnami/php/bin:/opt/bitnami/mysql/bin:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:$PATH"
    export PATH
    LD_LIBRARY_PATH="/usr/lib/jvm/java-7-openjdk-amd64/lib:/opt/bitnami/sqlite/lib:/opt/bitnami/mysql/lib:/opt/bitnami/apache2/lib:/opt/bitnami/common/lib:$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH
  • Modify the JRE_HOME variable from JRE_HOME=/opt/bitnami/java to JRE_HOME=/usr/lib/jvm/java-7-openjdk-amd64 in file /opt/bitnami/apache-tomcat/scripts/ctl.sh

  • Modify the JAVA_HOME variable from JAVA_HOME=/opt/bitnami/java to JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 in both /opt/bitnami/scripts/setenv.sh and /opt/bitnami/apache-tomcat/bin/setenv.sh files

  • Restart all the Bitnami services using the ctlscript.sh script

    sudo /opt/bitnami/ctlscript.sh restart
  • Load the environment and check the Java version by running the commands below

    . /opt/bitnami/scripts/setenv.sh
    java -version
  • Visit the Apache Tomcat manager application to check the Java version currently running. You should see a "Server Information" section similar to the one below

Tomcat Manager App Server Information

Additionally, you can modify the /home/bitnami/.bashrc file for the new environment to be automatically loaded every time that you connect to your server by adding the line below to the end of the file

    . /opt/bitnami/scripts/setenv.sh

Best regards,

Gonzalo



Related Topics



Leave a reply



Submit