1

I just installed the Ubuntu Restricted Extras. I want to code using java. How do I open the installed Extras and use java. When I type "java" in Dash home, I get many results.

Thank you.

Sam
  • 66

2 Answers2

1

Well the restricted extras doesn't give Oracle's JDK for some reason. (Not for me anyway) There are many tutorials on how to install java. Many are convoluted and have you use extra steps that really are not needed. But here is how I install Oracle's JDK.

First type in the terminal:

sudo apt-get purge openjdk* 

To get rid of openjdk if it is there.

Then download a nifty .rpm to .deb converter called alien

sudo apt-get install alien

Download Oracle's JRE or JDK .rpm file.

Then run

sudo alien jdk-7u45-linux-x64.rpm --scripts

if the .rpm name is different replace mine with the correct one. Alien will convert the .rpm to a .deb The --scripts prefix is important, do not leave it out or it will not convert the .rpm.

Run the .deb

Now you have Oracle's JDK. Don't install Eclipse from the Ubuntu Software Center. For some reason the Software Center installs OpenJDK and replaces it with the Oracle one. The update alternatives doesn't point to the directory Oracle's JDK is installed in. Your best bet to run Eclipse is to download the .zip file and unpackage it somewhere.

The draw back is you have to run jars in the terminal. Not really a drawback from my perspective, but some people want to just double click. I find though that using the terminal actually shows what is kind of going on and it helps with finding bugs easier.

1

If you just want to write a program you should be totally fine with OpenJDK Install openjdk-7-jdk from the Ubuntu repositories.

If you really need Oracle JDK, you can add ppa:webupd8team/java and install oracle-java7-installer.

David Foerster
  • 36,890
  • 56
  • 97
  • 151