Let us learn about some basic terminologies related to JAVA which we came across while installing. In this post, we will learn about the following terms
- Java SE
- JDK (java development kit)
- JRE (java runtime environment)
- Javac, compiler
- Java, interpreter
- JVM (Java virtual machine)
- PATH variable
- CLASSPATH variable
There are four platforms of the Java programming language: Java Platform Standard Edition (Java SE), Java Platform Enterprise Edition (Java EE), Java Platform Micro Edition (Java ME) and Java FX.
All Java platforms consist of a Java Virtual Machine (JVM) and an application programming interface (API).
But in general, when we think of Java programming language, we think of Java SE API. Java SE’s API provides the core functionality of the Java programming language. It defines everything from the basic types and objects of the Java programming language to high-level classes that are used for networking, security, database access, graphical user interface (GUI) development, and XML parsing.
In addition to the core API, the Java SE platform consists of a virtual machine, development tools, deployment technologies, and other class libraries and toolkits commonly used in Java technology applications.
In the previous post, we installed JDK 8u91. For information on features and fixes included in this release, see the JDK 8u91 release note.
JDK (Java Development Kit)
As the name suggests JDK is a kit which contains everything that will be required to develop and run Java application. It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (javadoc) and other tools needed in Java development.
Allow me to introduce you to specified tools, not in real details but just definitions so that you can understand what is happening when you use them.
The Java Runtime Environment provides the minimum requirements for executing a Java application. It consists of the Java Virtual Machine (JVM), core classes, and supporting files. You may be confused between JDK and JRE. Simply stated, if we just want to run java programs and applets we install JRE but to develop as well as run them we need JDK.
javac, the compiler
Java source files are simple text files saved with a .java extension. After writing and saving Java source code, the javac compiler is invoked to create .class files (byte code).
How to use? In command prompt type javac file1.java
java, the interpreter/loader
once the .class files are created, java command is used to run java program.
How to use? In command prompt, type – java MyClass
JAR stands for Java Archive. A jar file is basically a zip file containing .class files and potentially other resources (and metadata about the jar itself). Jar files can contain any kind of files, but they usually contain class files and supporting configuration files (properties), graphics and other data files needed by the application. Jar files provide ease of distribution and also authentication.
How to use?
To know about a jar file, in the command prompt type – jar tvf jarfilename.jar
javadoc, a documentation generator
Javadoc is used to generate Java code documentation in HTML format from Java source code which has required documentation in a predefined format.
How to use? In command prompt, type – javadoc file1.java
JVM (Java virtual machine)
For fine clarity I recommend you to first go through my post introducing java platform.
JVM is an abstract layer between java applications and the underlying platform. Its job is to bridge the gap between the high level language, JAVA and the low level language of the machine. It is a part of JRE. It itself is machine dependent but allows java portability, i.e. it enables java bytecode to run on any platform. Java program cannot run on a platform until an appropriate JVM is created for it and that JVM has been installed on it.
Always remember one thing, whenever we talk about JVM we may be referring to any of the following things –
- Abstract specification
- Concrete implementation
- Run time instance
The abstract specification defines the behaviour of the machine in terms of subsystems, memory areas, data types, and instructions. It is just a concept.
The concrete implementation exists on the platform where java applications are executed. And runtime instance hosts a single running java application.
PATH is an environment variable which maintains a list of directories for searching executable programs. The directories are separated by semi-colon ‘;’.
When we launch a program from the command line, the operating system uses the PATH environment variable to search for the program in our local file system.
Therefore, it is necessary to specify the path of directory which would contain all the executable files of JAVA before we can use them. And this is what we did while setting PATH variable.
Java Compiler (“javac”), Java interpreter (“java”) and other Java tools search for classes used in our program in the following order:
- Platform (bootstrap) classes
- Extension Directories: You can copy the external JAR files into Java Extension Directory.
- User classes search path (in short, class path): determined in the following order:
- Defaulted to the current working directory (.).
- Entries in the CLASSPATHenvironment variable, which overrides the default.
- Entries in the -cp(or -classpath) command-line option, which overrides the CLASSPATH environment variable.
The CLASSPATH environment variable includes directories (containing .class files) and JAR files (a single-file archive of class files). If CLASSPATH is not set, it is defaulted to the current directory. If you set the CLASSPATH, it is important to include the current working directory (.). Otherwise, the current directory will not be searched.
The PATH environment variable is applicable to all applications; while CLASSPATH variable is only used by Java.