Trying to move from GNU Java 1.5 to Oracle Java JDK 1.6 in my Debian Lenny. I have installed new Java into /opt/. But what I should do next? If I type java command I still have old one. I suppose I should create symlink java -> /opt/JDK1.6/bin/java instead of existing one java -> /etc/alternatives/java. What else I should do?

  • 1
    Why not install the packaged Sun JDK from the Lenny repositories? I know you ran into issues trying to install them, but if you slowed down a bit and let people help you resolve your previous issues you’d probably find it better in the long run. Jun 10, 2018 at 16:48
  • Because I have feeling that Lenny repositories will provide me with very old Java. Possible I'm wrong and I would be glad to do that. But how to install java 1.6 from Lenny repositories?
    – vico
    Jun 10, 2018 at 19:13
  • That’s a good point, the Lenny repositories only have 6u26. To install 6u45, see my answer to one of your previous questions. (This will also take care of setting up alternatives etc.) Jun 10, 2018 at 21:07

1 Answer 1


In order to change where /etc/alternatives/java points, use update-alternatives. Here's an example of how to do that:

sudo update-alternatives --install /usr/bin/java java <path to your java executable> 1


After you use the --install option, run:

sudo update-alternatives --config java

And select the one you just installed.

There's a better way than installing manually, though. If you use the make-jpkg utility, you can create a .deb that can be installed with built-in tools.

Here's an example of how to do this:

First, download the JDK you want from oracle. You want the tar.gz format for the correct architecture. In this example, I'm using Java 8, but make-jpkg supports Java 6 too. Then run:

make-jpkg jdk-8u171-linux-x64.tar.gz
sudo dpkg -i jdk-8u171-linux-x64.deb
sudo update-alternatives --config java
sudo update-alternatives --config javac

Of course, there's also the OpenJDK Java packages, but I assume you have a good reason to use Oracle's Java.

You must log in to answer this question.

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