Installation for different OS:
- Windows:
- Download Java8 JDK depending on the compatibility of the machine; it's different for Windows(32bit) and Windows(64bit).
- After downloading the file, run the .exe file and follow the instructions to install Java on your computer. After installation, you need to set up the environment.
- Go to Control Panel -> System and Security -> System. Under the Advances System Setting option click on Environment Variables as highlighted below.
- Now, you have to alter the “Path” variable under System.
- You need to choose the path where you have installed Java “C:/Program Files/Java/jdk/bin” or “C:/Program Files(x86)/Java/jdk/bin”.
- Click on OK, Save the setting, and you are ready to go. Now check whether the installation done is successful or not. Open the cmd and type javac -version. You will notice that java is running on your machine.


2. Linux Operating System:
- In Linux, there are numerous ways to install Java. But we will prefer the easy way to install java using a terminal.
-
Open the terminal, then type the following command.
Sudo-apt get install OpenJDK-8-the command is shown below for
-
The command below for the “JAVA_HOME”(Environment Variable).
Export JAVA_HOME = /usr/lib/jvm/java-8-openjdk
-
Type the command shown below for “PATH”(Environment Variable).
Export PATH = $PATH:/usr/lib/jvm/java=8-openjdk/bin
- We are done setting the environment.
3. macOS Operating System.
- Open the terminal from the application folder.
-
Now enter the following command.
java –version
javac –version
- Once we are done installing JDK now, we need to set up the java home environment variable.
- Enter the command ls -al.
-
Enter the command to check the proper installation of java in macOS
echo $JAVA_HOME
- After this, go to the root folder in the terminal and write the command ‘touch./bash_profile’. You can see the bash profile is created.
-
Edit the .bash_profile created for java; you need to enter the command marked below.
Export JAVA_HOME = $(/usr/libexec/java_home)
-
Verify this command by typing the command
source.bash_profile
echo $JAVA_HOME
You can also read about the topic of Java Destructor. and Swap Function in Java
Popular Java Editors:
Notepad: In windows, you can simply use a text editor like Notepad, TextPad.
Netbeans: A Java IDE is an available source and free to download.
Eclipse: A Java IDE developed by the eclipse open-source community can be downloaded easily.
You can also check about Java Tokens here.
FAQs:
Q: Why do we need to set environment variables in JAVA?
A: Environment variables are set to permit access to command-line tools and empower different devices to connect with SDKs more easily. For instance, with Java on Windows, on the off chance that the environment variable is not set on the PATH, running javac is significantly more cumbersome because you want to type in the full path to the command each time:
Q: How to set environment variables in Java to run an application?
A: To run the Java application, install a Java Development Kit (JDK). Furthermore, there are two environment variables to set. One is a path, and the other is a classpath variable. First of all, download the latest JDK from its authority website of Oracle.
Key Takeaways:
In this blog we covered the following points:
- What are the different platforms in Java?
- How to install java on different Operating Systems like Windows, Linux, and macOS.
- What are the current popular Java Editors?
If you want to know more about the installation of Java on different operating systems.
Go to this Java download.
Check out this problem - Root To Leaf Path
Related article:
Java Tokens
Difference between JDK, JRE and JVM
Why is Java Platform Independent
Java Verify
Eclipse ide for Java Developers
Addition of two numbers in java