You need to follow some simple steps for installing Sun Java Development Kit(JDK) & Java Runtime Environment(JRE) in Ubuntu Linux. They are:
Step 1: At the initial stage ,check whether the MULTIVERSE repository is enabled or not.
For this Click on System->Administration->Software Sources->Select Multiverse->Close.
Step 2: Open TERMINAL and type the following to install JDK and JRE :
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
Note: (1):If you want to use command-line interface , press Ctrl+Alt+F1 and enter the user name and password. For returning to the graphical user interface , press Ctrl+Alt+F7.
(2):You may need to update the runtime or development kit for the java language. For updation type sudo update-java-alternatives -s java-6-sun at the terminal.
Step 3: Set up the environment variable.
For this , do the following:
Type the following at the terminal:
vi $HOME/.bash_profile
Type the following in the opened text file:
export JAVA_home=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin
Save and close the file. For this , press ESC and type :wq and press enter.
Warning: Linux is case-sensitive.So,take care of the case of the command entered.
Note: If you want to know the version of JRE installed , use the following command :
java -version
For compiling the java program , go to the specified directory and type
javac filename.java
For executing the program , use the command
java filename
ENJOY THE PROGRAMMING.
Step 1: At the initial stage ,check whether the MULTIVERSE repository is enabled or not.
For this Click on System->Administration->Software Sources->Select Multiverse->Close.
Step 2: Open TERMINAL and type the following to install JDK and JRE :
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
Note: (1):If you want to use command-line interface , press Ctrl+Alt+F1 and enter the user name and password. For returning to the graphical user interface , press Ctrl+Alt+F7.
(2):You may need to update the runtime or development kit for the java language. For updation type sudo update-java-alternatives -s java-6-sun at the terminal.
Step 3: Set up the environment variable.
For this , do the following:
Type the following at the terminal:
vi $HOME/.bash_profile
Type the following in the opened text file:
export JAVA_home=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin
Save and close the file. For this , press ESC and type :wq and press enter.
Warning: Linux is case-sensitive.So,take care of the case of the command entered.
Note: If you want to know the version of JRE installed , use the following command :
java -version
For compiling the java program , go to the specified directory and type
javac filename.java
For executing the program , use the command
java filename
ENJOY THE PROGRAMMING.