Results 1 to 6 of 6

Thread: update-alternatives: error: alternative javac can't be a slave of java...

  1. #1
    Join Date
    Jun 2008
    Beans
    130

    update-alternatives: error: alternative javac can't be a slave of java...

    Hello, I'm trying to install Oracle JDK 1.6.0_30 on Ubuntu Server 11.10. OpenJDK 6 and OpenJDK 7 are already installed, and I'm setting up OracleJDK using update-alternatives.

    I've done this with no problems on my Ubuntu Desktop 11.10 workstation, but the same process is resulting in this error on the server:

    Code:
    update-alternatives: error: alternative javac can't be a slave of java: it is a master alternative.
    The setup process is:

    1. Download, extract, and copy the extracted jdk1.6.0_30 to usr/lib/jvm/jdk1.6.0_30.

    2. Setup default-jvm soft link and $JAVA_HOME:
    Code:
    ln -s /usr/lib/jvm/jdk1.6.0_30 /usr/lib/jvm/default-java
    Add $JAVA_HOME to .profile:
    Code:
    export $JAVA_HOME='/usr/lib/jvm/default-java'
    3. Use this script to add jdk1.6.0_30 to the update-alternatives java list.

    The error occurs at #3 when I use the script. I can slave javac to java on Ubuntu Desktop, but not on Ubuntu Server. Any idea why?
    Last edited by Kurtosis; February 7th, 2012 at 07:40 PM.

  2. #2
    Join Date
    Dec 2010
    Beans
    570
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: update-alternatives: error: alternative javac can't be a slave of java...

    Yes the sad thing is that the way that alternatives is configured for java it doesn't place all of the JDK/JRE commands in a single alternative as slave commands it adds some of them individually.

    This is an issue because if you "fix" this you break the updates because future updates will try add any new javac as its own alternative and it will fail causing the update to fail.

    I had created a great little script that updated the alternatives for all of the Java commands all you needed to do is supply the JDK/JRE directory and it set all of that versions command as slaves for the java alternative. Then I ran into this issue and had to remove my custom alternatives.

  3. #3
    Join Date
    Jun 2008
    Beans
    130

    Re: update-alternatives: error: alternative javac can't be a slave of java...

    Ok, thanks. In your script, did you try separating out javac from the java part? I'll try that in mine and repost the results.

    Also, strange that this isn't a problem on Ubuntu Desktop, just Server, same version and everything.

  4. #4
    Join Date
    Dec 2010
    Beans
    570
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: update-alternatives: error: alternative javac can't be a slave of java...

    I thought about separating the alternatives for java and javac so that java got the JRE stuff and the javac got the JDK but I really did not feel like working around what I considered a broken implementation.

    It is odd that you did not run into this on the Desktop edition because that is where I had me issue.

    On server I don't use the standard Tomcat/Apache installs I have my own location for them and I have different accounts for different application and I set the JAVA_HOME and PATH in the users profile for the JRE/JDK for that application user.

  5. #5
    Join Date
    Jun 2008
    Beans
    130

    Re: update-alternatives: error: alternative javac can't be a slave of java...

    Quote Originally Posted by hawkmage View Post
    On server I don't use the standard Tomcat/Apache installs I have my own location for them and I have different accounts for different application and I set the JAVA_HOME and PATH in the users profile for the JRE/JDK for that application user.
    I've been thinking about doing that too lately. I already install all the rest of the app stack in /opt, may as well put JDK in there as well, and just use JAVA_HOME and PATH to point to it.

  6. #6
    Join Date
    Dec 2010
    Beans
    570
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: update-alternatives: error: alternative javac can't be a slave of java...

    I actually create a separate volume mounted on /apps and put all of the application related stuff there.

    I also separate the binary files of Tomcat and Apache from the applications config through the use of CATALINA_HOME, CATALINA_BASE and APACHE_HOME. This way I have one copy of the binaries of the versions of Tomcat/Java/Apache I use making patching easier. I use a few scripts to set the environment variables and define symlinks that connects the application environment with the needed binaries.

    This may be more than you want to get into but it really helps when you are hosting dozens of applications that are using differnet versions of Tomcat/Java/Apache.

    (I can not share the scripts since the company I work for owns them but the concept is mine)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •