Showing posts with label JDK. Show all posts
Showing posts with label JDK. Show all posts

Monday, September 7, 2026

How to Set Java Version in Linux

How to set java version in Linux or Unix.


Here I have used Linux Mint, but this setup can work for other Linux distributions. 

Checking the existing java version on your linux machine.
dev@developer-desktop ~ $ java -version
java version "1.6.0_36"
OpenJDK Runtime Environment (IcedTea6 1.13.8) (6b36-1.13.8-0ubuntu1~12.04)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

 

The above command shows the existing java version installed on this machine. Now I can check the alternative version to set. These alternative versions are available for installation. The below command will prompt with sudo password and selection number. Try with below command :


dev@developer-desktop ~ $ sudo update-alternatives --config java
[sudo] password for dev: ***********
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
  1            /usr/bin/gij-4.6                                 1046      manual mode
  2            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  3            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1051      manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode.

In the above command, I have opted the Selection 3 , because I want java 1.7 version. You can choose as per your requirements. 


Now you can check whether version 7 is installed or not ? Try the check version command again as below.

dev@developer-desktop ~ $ java -version
java version "1.7.0_79" -----> This is newly installed.
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.12.04.1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)




Hope this will help you.

Thursday, September 11, 2014

Java Command Not Working from Command Prompt in Windows

This issue I faced with window 8. When I was trying to execute java command from command prompt it was showing this error.After long time analysis I found the reason for this issue. This issue is really ambiguous.Its normally a path issue, if your class path has configured proper and still its not working then it might be a big reason to worry.

Solutions 1 :- Check your class path , if not set then use the below command to set.

path = your_java_installation_bin_path; 

Solutions 2 :- Probably there is few more java.exe file in your windows directory (i.e. C:\) .Normally when windows automatic updates works on your machine it may be install java into some other reference directory and it may be the cause.So, when you are trying to execute the java command from command prompt its not able to locate the exact path . 
 
As a solution , I have done this by removing all the java.exe files from windows directory.

You can search the java.exe file from windows directory and remove all java application files , except your own java installation directory. After removing all those extra java application files its working fine for me. Below the screen shot for finding and removing the java application file.