In order to run java programs/applications in your system you need to have a JRE ( Java Runtime environment ) installed on your system.
And if you want to code in Java and compile your application, then you need to have a JDK ( Java Development Kit) installed on your system.
Note : As you can see that the JRE and JDK’s full forms are self explanatory about their purposes.
You can download the Java SE ( Standard Edition) from oracle official website.
Once you are done with JDK installation in your system.
You need to make sure that Windows can find the Java compiler and interpreter:
- Go to the folder where you installed Java in your system. Java -> JDKx.x.x_xx -> bin .
- [In windows ] Search -> Advanced System Settings -> Environment Variables -> System variables -> PATH.
- Add the path of your bin folder in the Path Variable.
- Ex: C:\Program Files\Java\jdk1.6.0_27\bin;
- Click ok and save the changes.
Setting Java path in Linux OS is pretty same as setting path in Windows OS. But here we use export tool rather than set.
Note : Here, we have installed the JDK in the home directory under Root (/home).
Check if Java is Installed correctly :
Open Command Prompt in the system. [Search CMD in the windows search]
Type: java -version and you should be able to view the version of Java you just installed.
Once you get the java version check if you have Java compiler got installed correctly.
Type: javac -version
You should get the same version in the next line.
1.8.0_1112 [in this case].
In next page, we will tell you how to write your first Java program and compile it.