How to Install Java Compiler
This article will help you get started with Java programming. You need to practice writing Java programs and the minimum requirement is a Java compiler. A compiler is a software program that converts the program code or source code into machine code which a computer hardware can understand and execute.
Before we begin to discuss about installing a compiler program, let us understand how you can write you code in Java. The Java offers two ways to write you source and compile it.
- Java Software Development Kit (SDK)
- Java IDE such as Netbeans
Java SDK is absolutely necessary for compiling Java programs. In the next section, we discuss about installing and running Java SDK.
Note that you must install the latest version all the time and this article applies only for windows system.
Downloading Java JDK
The first step in installing Java compiler is to download the latest version of SDK form oracle website.
On the download page, you will get the latest version of Java SDK standard edition. For this tutorial, standard edition is perfect, but you may download other versions also. Before you download you have to accept the “Oracle Binary Code License Agreement for Java SE” and proceed with the download.
The download may take some time depending on the speed of your computer and network.Once completed you may see a file like the one given below.
Installing Java SDK
To install the Java SDK , double click the downloaded file and setup will prepare to install.
Click next to continue the installation process.
The Java SDK setup offers you chance to customize your setup, make changes only when necessary. You can change the installation directory if the default installation directory or drive does not have enough space.
Click next to continue installation.
You will see custom setup dialog from setup installer. Once again if necessary change the default installation directory, otherwise continue with next.
The installer will take some time to complete the Java SDK installation. After installation you should see a completion screen, click close to complete the installation.
You may like to check the Java version installed, open command prompt (start > search > cmd) on your computer. Change directory to Java installation directory (C or D:\program files\Java\jdk-10.0.2) and run the following command.
You will see complete information about the current Java SDK installation.
It is very difficult to run java.exe from Java\jdk-0.0.2\bin directory every time. You must set the PATH to Java bin directory to run Java compiler from any directory.
To set the PATH, go to system properties > Advanced > Environment variables. Under User variables locate path and add path to bin directory(D:\Program Files\Java\jdk-10.0.2\bin).
Ssimilarly, go to System Variables, add the path to bin directory(D:\Program Files\Java\jdk-10.0.2\bin) , click OK and close the windows.
You can set the PATH and CLASSPATH using command line.
set path=%path%;D:\Program Files\Java\jdk-0.0.2\bin set classpath=%classpath%;D:\Program Files\Java\jdk-10.0.2\lib\*.jar
To write your Java source code use any text editor program and save your file with .java extension. You need to compile the program using command prompt using javac command which will create a <filename>.class file.
In the next article we will discuss, installing Netbean IDE 8.2, another popular way to write and compile Java code.