3 of 6 /opt is the way to go for Oracle JVMs. Recommended by Ubuntu. More accurate description of Oracle VM.

To install the Java Runtime Environment (JRE) run the following command:

sudo apt-get install openjdk-7-jre

This installs the Java JRE (Java Runtime Environment) which will allow you to run applications written in Java.

To install the JDK run the command:

sudo apt-get install openjdk-7-jdk

This allows you to compile Java applications to bytecode.

If you want the Oracle Java VM, which is a lot faster (optimized for embedded arm CPUs) and is also a developer preview (applications maybe buggy or crash) until some time into the future. Instead of the above instructions you need to download the file called Oracle JDK 8 (with JavaFX) for ARM Early Access on the Oracle Java 8 download page.

Remember to download the Oracle Java system on your Pi, or you won't be able to install it.

To install the Oracle Java System:

tar zxvf jdk-8-ea-b36e-linux-arm-hflt-*.tar.gz -C /opt
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.8.0/bin/java" 1 
sudo update-alternatives for other commands if needed.
java -version

Then it is all installed.

Another thing, if you have more then one Java runtime installed you have to check which version you use with the commando java -version. If the output is:

java version 1.5.0 gij (GNU libgij)

Then you are using a other java runtime. You can resolve the issue by running

sudo update-alternatives --config java

and choosing the OpenJDK or Oracle option.