Ubuntu seems to favour OpenJDK/JRE very much over Sun JDK/JRE. Even after I installed Sun JRE, JDK and plugin and spent some time plucking out OpenJDK-related packages, apt-get has installed them back with some packages as a dependency. Can this behaviour be corrected in favour of Sun Java packages? I'd like to have one and only Java stack installed (yes, it's a bit of OCD, but I like to have my systems clean) and want it to be Sun Java.

Update: as Marcos Roriz notes, the problem seems to be in default-jre (on which Java-dependent packages use to depend) pointing to OpenJDK, so the question seems to go about how to hack default-jre/default-jdk to point to Sun Java.

link|improve this question

56% accept rate
feedback

6 Answers

I think the problem is that some Java packages rely on default-jre which points to openjdk-jre. I don't think there is a easy way to permanetely uninstall openjdk. The thing is that you probably will bump on openjdk again when you install a java package/program.

But if you're willing to have both, is it easy to set the java runtime programs (java, javah, javap, and so on) to sun implementation. Do it:

sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts

or if you are a java dev (install the sdk and srcs):

sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-source

And set it as the default programs with:

sudo update-java-alternatives -s java-6-sun
link|improve this answer
Yes, I believe this is about default-jre. No, I really don't want to have both Sun and Open JDKs - this is what's the question about - to have one and only and let it be Sun JDK. Is there a way to hack default-jre to point to Sun JRE? – Ivan Jan 12 '11 at 0:05
Yep, I'll try to rebuild the default-jre package to point to sun-java this evening. Right now I'm @ work. – Marcos Roriz Jan 12 '11 at 11:46
feedback

You know i had this problem once about two year ago with Ubuntu 8.04 i think. There was a weird problem when using open jre and the problem was solved by using the sun jre. Here are the steps in the terminal.

sudo apt-get remove openjdk-6-jre default-jre default-jre-headless

sudo apt-get install sun-jave6-jre sun-jave6-bin sun-jave6-plugin sun-jave6-fonts (Everything Sun java related. Just to make sure)

After that if you removed openjdk then you only have sun java. If you did not remove it then you have both of them. To change from one to another do this:

sudo update-java-alternatives -l - This will show you the list of java engines to use.

The name of the java alternative is the one in the left. For example for openjdk it will appear something like this: java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk

So to set it to openjdk you would do this:
sudo update-java-alternatives -s java-6-openjdk

If you want to use Sun then do this (After installation of the sun packages)

sudo update-java-alternatives -s java-6-sun

I do not know what problem was solved back then (I think it was something to do with frostwire maybe) but anyway this will work for you. Let me know how it went. +1 if it goes good.

link|improve this answer
I've done this, but OpenJDK came back soon... – Ivan Jan 11 '11 at 22:16
You tested also sudo update-java-alternatives --set java-6-sun If the little monster persists remove the openjdk. – Luis Alvarado Jan 11 '11 at 22:24
I think the problem that he is saying is that openjdk keeps getting installed (because of default-jre). – Marcos Roriz Jan 11 '11 at 22:34
Whoops what Marcos said is right. Let me add it to the list. missed that one. – Luis Alvarado Jan 11 '11 at 22:49
feedback

Using Ubuntu 10.10,it seems you need to mark for removal libaccess-bridge-java first in Synaptic, and then mark openjdk-6-jre-headless.

I ended up with a list to be removed:

ca-certificates-java, icedtea-6-jre-cacao, libaccess-bridge-java, libaccess-bridge-java-jni, openjdk-6-jre, openjdk-6-jre-headless,openjdk-6-jre-lib.

This worked but it left a directory /etc/java-6-openjdk behind with assorted files and subdirectories within, which I isolated in a new directory. There have been no unusual effects, so presumably it is just a leftover remnant.

This left me with the Java I had downloaded directly from the Java website. However, despite having set it as default and creating the link to the Firefox plugins directory, it no longer worked. Installing sun-java6-jre and it's associated packages gsfonts-x11, odbcinst, odbcinst1debian2, sun-java6-bin, and unixodbc, via Synaptic, saw the Java plugin begin working again. Removing the link in the plugins directory and replacing it with the actual libnpjp2.so file did not work. Using a link to the libjavaplugin_oji.so files in either the ns7 or ns7-gcc29 directories in the Java installed through Synaptic did not work either. This suggests to me that to get the latest Java plugin in Firefox one can follow the instructions on the Java website, and that the integrated Linux Java of whichever variety is present is needed to run the downloaded Java, which then relies for it's operation on the files surrounding it once the plugin has been activated. While a full understanding of the code comprising Java and Linux would be required to really solve it's mysteries, perhaps these experiments are helpful in finding the reasons why two Java's may be needed in this case. At least it is possible to remove all Java as well, if anyone finds it useful to do so.

link|improve this answer
feedback
  1. Open System->Administration-> Synaptic Package Manager and then remove OpenJDK completely.
  2. Test version of Java typing java -version in shell (it will display Sun java only)
  3. Type sudo update-java-alternatives -l
  4. you are done. Now you have only sun java installed and it's setup as default jdk

and it works only if you have two jdk installed and you wanna set sun-java as a default environment

link|improve this answer
feedback

The thing I do on new Ubuntu 10.10 machines is

  • add java-6-sun,
  • remove openJDK (add sun Java first otherwise a bunch of things will be removed like tomcat, etc)

Then it is fine for me, no more openJDK dependencies

link|improve this answer
java-6-sun isn't it the ubuntu-default-package, or is it? – Fabian Zeindl May 20 at 15:18
feedback

Delete openjdk and icedtea:

apt-get purge openjdk-\* icedtea-\* icedtea6-\*

add the following to /etc/apt/sources.list

deb http://ppa.launchpad.net/webupd8team/java/ubuntu YOUR_UBUNTU_VERSION_HERE main

install Sun/Oracle JRE or JDK:

apt-get install oracle-jdk7-installer
apt-get install oracle-java7-installer 
link|improve this answer
2  
And after this you are left with no Java at all... The question actually refers to who to replace one with the other, not how to remove OpenJDK from your system. Add a bit more information to your answer, the question cannot be answered only by following these steps. – Bruno Pereira Apr 18 at 15:25
Thanks. I updated it. – Fabian Zeindl Apr 18 at 20:12
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.