Ubuntu – Eclipse does not want to use openjdk-7


I am on a new installation of Ubuntu. I install all the updates, and then restart. I then install openjdk-7-jdk from apt, then I restart. Then I install eclipse-platform, eclipse-jdt, and eclipse-cdt. I then launch Eclipse. When I check the build path for my imported projects it decided that during the eclipse-platform installation to install openjdk-6. Okay, cool. The problem is that I can't use openjdk-7 AT ALL. There is no option to use it in the build path library manager. How can I change it so it uses openjdk-7? I tried reinstalling it already, didn't do anything. Just told me it was already installed.

EDIT: Failed at the title, fixed.

Best Answer

So the solution was to manually install Eclipse so that apt didn't install dependencies that were not actually dependencies.

Installing Eclipse Manually

So download Eclipse from here. I decided to use the Classic version, but if you want to use the Java EE version I'm sure that it will work.

Download it to a directory and open your terminal. Navigate to that directory by using the command

cd <insert directory path here>

Make sure that there are no files starting with eclipse in that folder. If there are then move them out of the folder temporarily. Then do this command:

tar -xzvf eclipse-*


sudo mv eclipse /opt/eclipse

Then you'll need to create a .desktop file for Eclipse in /usr/share/applications/eclipse.desktop so you have a shiny icon on your bar thingy (if anyone knows the offical name of the little bar on the side then please edit this answer so that it contains it). Do these commands

sudo touch /usr/share/applications/eclipse.desktop
sudo gedit /usr/share/applications/eclipse.desktop

Paste this in that file:

[Desktop Entry]
Comment=Integrated Development Environment

Then create a symlink in /usr/local/bin so you can run it from the terminal using the command eclipse:

cd /usr/local/bin
ln -s /opt/eclipse/eclipse

That's it!

Eventually, I decided to use Sun's Java because OpenJDK was a substitute, and if I was going to do it manual, I might as well go the extra mile.