Java is a highly secure, object-oriented programming language that can run on any platform and is portable. This advantage of Java makes Java the most used language in the world.
However, in order to use and develop Java properly, it is necessary to set a basic environment first.
Setting the default environment is not difficult. Just follow these 4 steps to set up the basic environment to use Java.
1. Download Java
First, access Oracle home page and download the JDK (Java Development Kit) for your operating system.
When you access the site, you can see several versions of JDK. Find the required version and install it.
2. Installing the Java JDK
After downloading the JDK, double-click the downloaded JDK file to install it. The installation process is not difficult. Please refer to the image below.
It is recommended that you uncheck “Use Java Content in Browser” on the Custom Setup screen for security reasons. Allowing browsers to use Java content allows hackers to remotely execute code on vulnerable systems.
3. Setting Java environment variables
When you finish installing the JDK, you need to set the JAVA environment variable. This is the most important part of preferences for Java development.
Set JAVA_HOME, PATH and CLASSPATH variables for JAVA development environment.
The CLASSPATH variable is not a required variable at the moment, but it is recommended that you set it beforehand because it is used when you need to use an external library or to interact with other programs.
To set the Java environment variable, click System> Change Settings in the Control Panel to open the System Properties window.
When the System Properties window opens, click the ‘Environment Variables’ button at the bottom.
Click the Environment Variables button and set the following variables when the environment variable setting window appears.
- Variable name: JAVA_HOME
- Variable Value: The path where the JDK is installed
The reason for setting the JAVA_HOME variable is to manage multiple JAVA versions. This variable is used to set the PATH and CLASSPATH to be set later.
This is convenient because if you install a new version of Java later, you only have to change the JAVA_HOME variable.
System variables for environment variables include the PATH variable. Find the variable and add %JAVA_HOME%\bin; at the front of the variable.
The reason for setting the PATH is to allow JAVA commands to be executed from anywhere on my computer. This tells to system you where JAVA is installed.
JAVA_HOME points to the root folder where Java is installed and there is an bin folder under this folder. The bin folder contains Java executables.
- Variable name: CLASSPATH
- Variable value: %JAVA_HOME%\lib\tools.jar;
CLASSPATH is not used when using native libraries. However, it is a variable that is used when an external library is used or when it needs to be linked with another program.
4. Java command test
If you have set all the environment variables, you should check if the Java environment variables are set correctly.
If you open the terminal and type javac, the code is output as shown below.
We live in an era that we do a lot of work through computers. Perhaps it is also important to learn computer language as much as we try to learn other foreign languages.
Maybe, Setting the development environment well is a good starting point for learning the programming language of your computer.