JDK Java Compiler: The Java Development Kit

Written by:  • Edited by: J. F. Amprimoz
Updated Dec 26, 2008
• Related Guides: Sun Microsystems | Java

In this article we tell you how to acquire a Java compiler by downloading the Java Development Kit, more popularly known as the JDK. We also tell you how to prepare your program for compiling and execution.

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:

http://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:

JDK Java Compiler Bin Folder
click to enlarge

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


Comments

Showing all 5 comments
 
Noel Kalicharan Oct 24, 2010 1:11 AM
Response to Mounica
Type "Java Development Kit" in your search engine or click on the link in the article above under "How To Acquire The JDK Java Compiler".
Mounica Oct 23, 2010 4:32 AM
Java
Where I can download Java with Javac,javajdb,ava,etc(java Developer Kit)
Noel Kalicharan Aug 28, 2010 1:31 PM
Response to Sheetal
Programs that are hundreds of lines long should compile within a few seconds. Is your program compiling eventually or not at all? Are things generally slow on your computer or is it just the Java compilation? The only thing I can think of is that some malware (virus, spyware, etc.) may be slowing down your system. On any normally functioning computer, the compilation is generally quick, especially for short programs.
Sheetal Aug 28, 2010 8:46 AM
slow comilation
command prompt takes very long to compile a java file... what can be the reason?
plz help...
andrew Aug 20, 2009 2:43 AM
get a java compiller
please where can i download a java compiller
 
blog comments powered by Disqus
Email to a friend