There are two types of java installations:
- JRE (java runtime environment) - which lets you ‘run’ java applications
- JDK (java development kit) - lets you ‘develop’ java applications.
To check if you have #1 installed and working correctly:
You should see something similar if you have it installed:
:~> java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
To check if you have #1 functioning well in browsers, go to Verify Java Version and click verify java version button.
If you are working on a project, which needs java only to run (not to develop) then you can install JRE. There are a number of ways you can do it. I have also packaged one installer which will download the JRE from Oracle’s site, and installs it for you. It also creates necessary symlinks so it works with browser. You can install it from here if you want:
Index of /repositories/home:/wildnux/openSUSE_12.3
If you are working on a project to ‘develop’ a java application, you should have JDK. Now, you can use proprietary Java from Oracle (which most people use) or you can use OpenJDK (which is opensource). Both are free to use. I have had some problems when using OpenJDK with other applications that were developed and build with Sun’s Java before. So personally I just use Oracle’s JDK.
Without installing a JDK rpm, you can use JDK by doing the following:
- download the JDK from Oracle’s site: Java SE Downloads
(I have 64bit computer so I download the 64-but zipped file (eg: jdk-7u21-linux-x64.tar.gz) )
- I will then extract it to some directory say : /home/USERNAME/jdk/
(such that inside that directory i will have now bin, db, include, jre, lib, man, etc.)
- I now set my JAVA_HOME environment variable to that directory. I do that by editing .bashrc file in my home directory (create if not there) and adding:
# for JDK
(dont forget to change USERNAME to your username )
- Log out and log back in. (or start on a new konsole) Now your application/ project should work.
To do a quick check you can do:
execute “which javac” without quotes in konsole, it should give you : /home/USERNAME/jdk/bin/javac
execute “javac -version” without quotes in konsole, it should show you version number similar to:
~> javac -version
The advantage of this method is that you have the whole JDK in your ~/jdk/ directory, you can update it to newer version by just downloading a new one and delete/move the old one, and extract the new one to the same location.
Note that you can use symlinks (shortcuts) instead of extracting directly into ~/jdk, you can just extract to /home/USERNAME/java/jdk-version-blah-blah/ and then just create a symlink using:
ln -s /home/USERNAME/java/jdk-version-blah-blah /home/USERNAME/jdk
This way you can keep multiple JDK versions inside ~/java directory and just link to the one that you want to use.