What Is Java? - Basics of Java Programming
- javastrokes
- Sep 5, 2016
- 2 min read
Java is a general purpose programming language and it has features that support the object-oriented, procedural and functional paradigms. One of the most important features of Java is its “write once, run anywhere” (WORA) feature. This feature lets you to write a Java program once and run it on any platform.
For example, you can write and compile a Java program on your windows and run it on Linux, Macintosh, or UNIX machine without any modifications to the source code. It means, your Java program runs on any computer with a JVM. Because a Java program is compiled into an intermediate language called byte code. Byte code is platform independent and byte codes are specific to JVM. A virtual machine, called the Java Virtual Machine (JVM), is used to run the byte code on each platform.

JVM is part of JRE (Java Runtime Environment) and it is a program implemented in software. A JRE is available for different operating systems. The main job of a JVM is to transform the byte code into executable code according to the platform it is running on. It means, Java Virtual Machine interprets the byte codes and runs the Java program in its native environment.
Java was designed as machine independent programming language and to be used in the distributed application development.
What is a Java Program?
Java program is written using the Java programming language, which contains a set of instructions to be executed to perform some tasks. Creating a simple Java program involves three steps: In the first step, you will write the source code for your Java program, in the second step you will compile the source code of your Java program and finally you will execute or run the compiled Java program. You can use an Integrated Development Environment (IDE) such as Eclipse, NetBeans to develop, compile and execute your Java programs or applications.
Different Parts of a simple Java Program
The first part of your program contains "Package" statement which has two parts (com.javaaspirant). Package statement must have at least one part. Package name will be stored in a host-specific file system and each part of a package name specifies a directory on the host system.
The second part of your program, has "import" statement which also an optional. It allows your program to import the necessary classes and interfaces from the predefined or user defined packages. Using import declarations, you can save some typing and makes your code cleaner and easier to read. You can have any number of import statement declarations in your program. You can two different types of import statements as mentioned below:
import com.javaaspirant.beans.Employee;
import com.javaaspirant.beans.*;
Here, first import statement allows you to import the specific "Employee" class/interface into your program, whereas the second one imports all the classes and interfaces of the specified package into your Java program.
Type declaration is third part of your Java program. Look at the simplest form of class declaration, given below:
Type (Class / Interface) Declaration: Parts of a class declaration in a Java source code

Comments