Java Basics

Java Development Kit: Starting with the Java JDK

In this tutorial we will present and describe the Java Development Kit (JDK). The JDK is a development environment for building applications, applets and components, using the Java programming language. The JDK among others includes the Java Runtime Environment (JRE), the Java compiler (Javac) and the Java APIs. The tools offered by the JDK are written in the Java programming language and can be executed on the Java platform.

In this tutorial we will show you how to install and use the Java Development Kit in a Windows 7 computer, with a 64-bit architecture and with Java 1.7.0_51 currently installed.

Download the JDK for Windows

  • First of all, you must visit the official download page here.
  • Then, you must accept the Oracle’s License agreement, in order to be able to download the JDK.
  • Find and click on the version that corresponds to your machine’s architecture, either 32-bit or 64-bit.
  • In the appearing dialog box, click on Save, in order to download the file to your local system.
  • Close all running applications, including the web browser.

Install the JDK in Windows

Once the download procedure is complete, we are ready to install Java in our machine. Navigate to the folder where the executable file is located and double click on it, in order for the installation to start.

Click on Next on the appearing dialog box:

jdk_1.7_51_install_WM

Then, if you don’t want to change the default installation directory of Java, click on Next:

jdk_1.7_51_install_setup_WM

A new dialog box shall appear that aims to install the new JRE. Again, if you don’t want to change the default installation directory, click on Next:

jdk_1.7_51_install_jre_WM

Wait for the JRE installation to complete. If no errors were encountered during the installation, the following dialog box shall appear:

jdk_1.7_51_install_complete_WM

Close the window. Well done, the latest version of the JDK has been installed to your computer!

Start using the JDK

As we already mentioned, the JDK contains the JRE and the Javac. These tools enable the development and execution of Java applications and applets.

Using your favorite text editor, copy and paste the following code snippet:

HelloWorld.java:

class SampleExample {
     public static void main(String[] args) {
          System.out.println(“Hello World!”);
     }
}

Using the Windows command line, navigate to the directory that contains the newly created HelloWorld.java file and execute the following command:

javac HelloWorld.java

This command makes use of the Java Compiler, which compiles our source program and creates the HelloWorld.class file. This file contains Java bytecode that can be executed by the following command:

java HelloWorld

The output of the aforementioned command is:

Hello World!

Notice that in case your source code contains errors, Javac will report each one of them. Obviously, you must fix them in order for the compilation procedure to complete.

Final Comments on the JDK

  • The development procedure of an application can be improved if you make use of the existing IDEs for Java, such as Eclipse and Netbeans. These IDEs provide a full programming environment for both development and execution of Java applications.
  • The JDK includes a bunch of useful and important tools, such as:
    • Appletviewer:  The Appletviewer is used to run and debug Java applets without a Web browser.
    • Javadoc: The Javadoc tool extracts all comments in a special format from Java source files and generates a HTML file tree that contains them.
    • Jar: Jar is an archive tool that packages multiple files into a single .jar archive file.
    • Jarsigner: The jarsigner is a Java application that is used to generate signatures for .jar files and to verify the signatures of signed .jar files.
    • Javaws: The Java Web Start software allows you to download and run Java applications from the Web. For more information, please to the Java Web Start tutorial here.
    • pack200: The pack200 tool is a Java application that transforms a .jar file into a compressed pack200 file using Java’s gzip compressor.

 
This was a tutorial on how to install and get started with the latest JDK in Windows.

Sotirios-Efstathios Maneas

Sotirios-Efstathios (Stathis) Maneas is a PhD student at the Department of Computer Science at the University of Toronto. His main interests include distributed systems, storage systems, file systems, and operating systems.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button