In today’s world, most applications are built using Java. This could be because Java provides an excellent cross-platform development environment along with a collection of libraries to work with. JDK(Java Development Kit) is one of the three core technology packages along with JRE(Java Runtime Environment) and JVM(Java Virtual Machine). It provides the tools and services required to develop software applications with ease.
The JDK plays an essential role in the Java application development lifecycle. In short, it is a software package that contains the compiler and class libraries to create Java-based applications. The JDK consists of a JRE, a compiler, an interpreter, and an archiver. The JRE contains tools to run Java programs, so the JDK requires it.
The packages part of the JDK are kits targeted to work on different types of development. The Enterprise Edition (Java EE) contains tools for Enterprise application development and Object-relational mapping. It focuses on web-based applications with servlet specifications. Usually, all JDK versions include a Standard Edition(Java SE). The Micro Edition, Java ME is also an available JDK package.
Downloading and Installing JDK
The Java SE JDK can be downloaded from the official Oracle site. There are many types and versions of JDKs available. Choose the most suitable one for your use.
The JDK you install determines the Java version you will use to code. This means that to compile a Java 8 code, you may require at least a Java 8 JDK.
On running the JDK installer, you will be prompted to select the Development Tools, Source Code, and Public JRE. These are optional. Installing Development tools provides services for monitoring, troubleshooting, security, and deployment for Java applications. The Source code contains the public classes of the core Java API. Public JRE allows other programs to execute Java Programs.
You can verify installing JRE and JDK by running "java -version" on the command prompt after navigating to the default locations of your OS.
Uses source code comments to generate documentation automatically.
Applet viewer
Debug and run Java applets without the help of a web browser
javafxpackager
Sign JavaFX applications and import related packages
javah
A ‘C’ header and stub generator that writes buit_in methods
javap
Disassemble class files
JConsole
For Java monitoring and management
jmap
An Oracle Memory map that prints heap memory details of a process
jinfo
Prints the configuration information of a Java process
jhat
An experimental Java heap analysis tool
apt
An annotation processing tool
extcheck
Detects conflicts in a jar file
jmc
Stands for Java Mission Control
jps
A JVM Process and Status tool that lists the JVMs of a target system.
jstack
It prints the stack traces of Java threads
jstat
A statistical monitoring toll of the JVM
jrunscript
A Java command-line shell script
javaws
A web start launcher for JNLP applications
jabswitch
For Java Access Bridge
xjc
Generates Java classes after accepting XML schema
jdb
A Java debugger
jarsigner
JAR signing tool and verifier
keytool
Manipulates the Keystore
Working with JDK
Create a file using a text editor with .java as its extension. Open the file and type your java code in it.
Use the JDK to convert this file into an executable file. This can be done by using the javac command in the command prompt. Now, the file’s extension would be .class. This compiled code is the Java bytecode.
The above command will create the Program.class file in the same directory.
Run the file using the java command
"C:\Program Files\Java\jdk-10.0.1\bin\javac.exe"Program.java
C:\Users\Documents>java Program
The javac command is stored in the /bin directory that contains many other useful tools. One such tool is the jar tool. A jar file contains a set of Java classes generated by the compiler. Compressed and arranged in a specific way.
We can convert .class file to .jar by using the following command.
Q: What is the difference between JDK, JRE, and JVM?
JDK is a Java Platform specification that helps developers create Java Applications by providing the necessary tools and libraries.
JRE is a Java component that runs Java programs. It is a part of the JDK.
JVM helps execute Java programs on any device or Operating system.
Q: What is the difference between Java SE, Java EE, and Java ME?
Java SE: used to develop standalone applications. We can execute software and deploy portable code for desktop and server applications.
Java EE: used to develop Enterprise scalable and multi-tiered applications with APIs like servlets, applets, WebSockets, etc.
Java ME: used for running Java programming language applications on small devices, like mobile phones, by providing small-scale virtual machines and libraries for small device application development.
Key Takeaways
To build scalable and reliable Java-based applications, a deep understanding of JDK is essential. This blog highlights the basics of JDK, its components, and its uses. It also explains how to install and work with JDK to compile and execute Java application programs.