How to Install JDK 8 on Windows and Get Started with Java Programming
By Stephen Bucaro
Java is a general-purpose computer programming language that is designed to run on all platforms.
It is intended to let application developers "write once, run anywhere" (WORA), meaning that
Java code can run on all platforms. Java applications are typically compiled to bytecode
that can run on any Java virtual machine (JVM) regardless of computer architecture.
Java is one of the most popular programming languages in use, particularly for client-server web
applications, with nine million developers, and more than three billion mobile phones run Java.
The JDK (Java Development Kit), officially named "Java Platform Standard Edition (Java SE)",
freely available from Sun Microsystems (now part of Oracle), is needed for writing Java programs.
JDK or JRE
The JRE (Java Runtime Environment) is needed for running Java programs. The JDK (Java Development Kit),
is need for writing Java programs. The JDK includes the JRE plus the development tools (such as
compiler and debugger). Before installing the latest JDK, you should uninstall any previously
installed older versions of the JDK/JRE.
To uninstall previous versions, in Control Panel, select Programs and Features, and un-install
all programs that begin with "Java", such as "Java SE Development Kit...", "Java SE Runtime..",
"Java Update...", etc.
32-bit or 64-bit Windows OS
Before you prepare to download the JDK, you should determine whether you have 32-bit or 64-bit
Windows. In Control Panel select System, and next to "System Type" you will see 32-bit Operating
System or 64-bit Operating System.
Download the JDK
To download the JDK, go to
ORACLE Java Downloads
and click on the Java Platform (JDK) 8u121 Download button. You'll need to check "Accept License Agreement".
Choose the JDK for your operating system, e.g., "Windows x64" (for 64-bit Windows OS) or "Windows x86"
(for 32-bit Windows OS). As of this writing, the name of the download for a 64-bit Windows OS is
jdk-8u121-windows-x64.exe.
After downloading the installation file (196 MB as of this writing), click on the file name and follow
the installer instructions.
Write the Hello-World Java Program
You can write Java programs with Windows Notepad (Under Windows Accessories). To write Java Programs
you must use a plain ASCII text editor, not a word processor like Microsoft Office. Word processors
place formatting codes in with the text, which will prevent the code from compiling. Before you
begin, understand that Java is very case sensitive, so ti does not consider "H" and "h" to be the same
character. In your text editor, type in the code shown below.
public class Hello {
public static void main(String[] args) {
System.out.println();
}
}
Save the file with the name Hello.java.
Compile the Hello-World Java Program
Before you can run a Java program, it must be compiled to bytecode. Bytecode is the instruction set
of the Java virtual machine.
To compile the Java program you can run the Java compiler (javac) from a command line. I recommend
using a batch file to compile your Java program. To do this, open another file in Notepad and
enter the text shown below.
"c:\Program Files\java\jdk1.8.0_121\bin\javac" c:\Users\Stephen\Desktop\Hello.java
pause
The first part in quotes is the path to your javac file. If you followed the defaults during
installation, it will be at the path shown (however use file explorer to verify that). The path
needs to be in quotes because the folder name "Program Files" has a space in it.
The second part is the path to your Hello.java program. As you can see, I like to work with files
on my desktop, so edit this file with your user name or the path to your Hello.java file.
The pause command on the second line causes the batch file to wait for you to hit any key before
closing. That way you will be able to read any errors.
Save the batch file with the name compile.bat. To execute the batch file, just double-click on it.
If you have no errors, the Java compiler will have created the file Hello.class.
|