How to Set Java Version and Javac Version

how to set java version and javac version

Oh Ya! Another new thing to learn.

Let’s roll, In this java tutorial or java tips, we will learn how to set java version and javac version.

The main reason is you might have a few different java versions installed in your machine. But Sometimes for some projects, we need to use some specific java version and javac version to build that project.

If you are curious enough to learn more about javac please click in this link – https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html

Now If you know enough about javac then you must know why it should be the same. If you compile with Java8 and try to read with Java7. The result will drive you crazy.

So here is the thing. In my machine, I have JAVA7 & JAVA8.

java versions

Now please don’t ask me why I am still using windows7 and java7. Long story, in short, I needed it.

As you can see that in my machine I have JAVA7 & JAVA8 both. Now we have to make our JAVA version and JAVAC Version are the same.

when we type java -version and javac -version in cmd it should show us like this.

java version and javac version in cmd

According to my CMD result. I already have this set up correctly. If your CMD is not showing then please try to do the following things.

Checklist Item 1:

In your windows please find the configure java option to view or change java settings. click this configure java option.

configure java

This will open a Java Control Panel. Now you how to open java control panel.

java control panel

  1. Now click Java Option.
  2. Click View
  3. Now from this Enabled option, you can choose which version you want to use by simply check the checkbox from the enabled option.
  4. Or you can decide which version you don’t want to use by simply uncheck the checkbox from the enabled option.

Restart your CMD and See any changes or not from your previous output. If not please follow the Checklist Item 2.

Checklist Item 2:

Checklist item 2 and the most important things for your java and javac version are the system variables of your machine.

Okay, let’s see this scenario. In my System variables inside the path %JAVA_HOME%\bin; was missing.

JAVA_HOME is set up as a = C:/Program Files/Java/jdk1.7.0_80 my desired JDK folder path.

let’s see what is the output came from CMD.

javac version is not recognised

Now you will see that

javac is not recognized as an internal or external command.

If you see clearly java version is also changed BTW still I have JAVA_HOME is set up with jdk1.7.0_80.
So inside the path, the JDK bin folder is really important to decide which javac will be used to compile your java code.

So follow this step to set up your JDK path

set java home and java bin

  1. in windows machine go to your computer -> properties > advanced system settings.
  2. click advanced and then Environment Variables
  3. under system variables set JAVA_HOME as your JDK folder path example: ” C:/Program Files/Java/jdk1.7.0_80
  4. then choose the path and then click edit and put your bin folder path in front as you see in the picture mentioned as 4 . Make sure you put  ;  at the end.
  5. If you don’t want to add JAVA_HOME variable then put in the path like this  ” C:/Program Files/Java/jdk1.7.0_80/bin;

Now restart your cmd and try to see your java version and javac version.

java version and javac version in cmd

OHH YAAA !!! here you are.

If this step doesn’t help you to set java version or javac version please let me know by comment below.i will find a way to help you. Thank you so much for reading this post.

If there is a mistake in this post or I missed any better way to do this please let me know by commenting below. I will appreciate your help and advice.

Leave a Reply

avatar
  Subscribe  
Notify of