JDK Java Compiler
Page content

How to acquire the JDK Java compiler

In Java Example: Algorithm and Program For Area Of Square, we wrote a Java program. In this article, we explain what you need to do to acquire the Java compiler and how to get your program ready for execution.

First, you need to get a Java compiler. You can compile and run Java programs using the Java Development Kit (JDK, for short) from Sun Microsystems. The latest version can be found at:

https://java.sun.com/javase/downloads/index.jsp

As of this writing, the latest version is JDK 6 Update 7. Go to the site and download JDK Update 7 (or whatever is the latest version). The programs in this series will work with JDK 5 and later.

When you run the downloaded file (by double-clicking on it), it will install the JDK in the default folder (the numbers after jdk may differ slightly):

C:\Program Files\java\jdk1.6.0_07

The compiler, javac.exe, is stored in the bin folder which should look like this:

You can, during installation, change the default folder and install it in C:\jdk1.6, say. You can make up whatever name you want for the installation folder.

How to store your program

In Java Example: Algorithm and Program For Area Of Square, we met the following program which calculates the area of a square:

import java.util.*;

public class AreaOfSquare {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int a, s; //declare the ‘boxes’ to hold side and area

System.out.printf(“Enter length of side: “);

s = in.nextInt(); //read and store length in s

a = s * s; //calculate area; store in a

System.out.printf(”\nArea of square is %d\n”, a);

} //end main

} // end AreaOfSquare

Next, you must type the program to a file named AreaOfSquare.java. You must use the same name as the name used in the program. This is required by Java. Also, Java programs must be stored in files that end with .java.

Java is case-sensitive; this means that it makes a difference if you use an uppercase as opposed to a lowercase letter. For example, AreaOfSquare is different from areaOfSquare.

You must store your program as a text file. You can use Notepad or WordPad. You can use Word (or another word-processor) but be sure to save it as a text file.

For convenience, we assume that you have created a folder C:\MyJava and will store your programs there.

Summary: we assume the JDK has been installed in

C:\Program Files\java\jdk1.6.0_07

and your program is stored in a file AreaOfSquare.java in the folder C:\MyJava.

In the next article, How To Compile and Run Java Programs, we show how to compile and run the program.

References

Java Programming - A Beginner’s Course

Related programming references

Article: How To Acquire The JDK Java Compiler

This post is part of the series: Introduction to Java Programming

This is a series which aims to discuss and teach Java programming to the complete beginner. Absolutely no programming background is assumed.

  1. Introduction to Java Programming - An Overview
  2. Java - Data, Variable and Algorithm Explained To A Beginner
  3. Java Example: Algorithm and Program For Area of Square
  4. Java Programming For Beginners - Test, Debug, Document, Maintain
  5. JDK Java Compiler: The Java Development Kit
  6. Java Programming For Beginners - How To Compile And Run Java Programs
  7. Data Types, Constants And Variables
  8. Java Programming For Beginners - Characters and printf
  9. Java Programming For Beginners - Part 9
  10. Java Programming For Beginners - Part 10
  11. Java Programming For Beginners - Part 11
  12. Java Programming For Beginners - Part 12
  13. Java Programming For Beginners - Part 13
  14. Java Programming For Beginners - Part 14
  15. Java Programming For Beginners - Integer Data Types
  16. Java Programming for Beginners - Part 16
  17. Java Integer Arithmetic For Beginners
  18. Java Programming For Beginners - Part 18
  19. Java Programming For Beginners - Part 19
  20. Java double to int and Other Conversions