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.


Solution 1:

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-*

Next,

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]
Version=4.2
Name=Eclipse
Comment=Integrated Development Environment
Exec=/opt/eclipse/eclipse
Type=Application
Icon=/opt/eclipse/icon.xpm
Terminal=false
NoDisplay=false
Categories=Development;IDE

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.

Solution 2:

You will find instructions for installing different software here: https://wiki.ubuntu.com/fballem/Software%2012.04#AdditionalRepositories

I install Oracle Java 7 first.

To do that, open a terminal and enter the following two commands:

sudo add-apt-repository ppa:webupd8team/java && sudo apt-get --quiet update
sudo apt-get install oracle-java7-installer

You will also need to be able to manage users and groups:

sudo apt-get install gnome-system-tools

There is a section in the installation instructions that describes how to properly install Eclipse.

Hope this helps,