What are the features in Java?
- Java is a high-level programming language originally developed by Sun Microsystems and released in 1995.
- Java is platform independent language and runs on a variety of platforms, such as Windows, Mac OS, and UNIX.
- Object Oriented - Java supports the object oriented programming language and everything is object and features developed in java which can be easily extended.
- Platform Independent − Java is compiled into platform independent byte code. This byte code is distributed over the web and interpreted by the Java Virtual Machine (JVM) on whichever platform it is being run on.
(Write once, run anywhere)
- Portable − Architecture-neutral and having no implementation dependent aspects of the specification makes Java portable. carry and run the java bytecode in any platform.
- Robust − Eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
- Multithreaded − It is possible to write programs that can perform multiple tasks simultaneously.
- Interpreted − Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is an incremental and light-weight process.
- High Performance − Java uses Just-In-Time compilers and provides high performance
- Distributed − Designed for the distributed environment of the internet.
- Dynamic − Java is considered to be more dynamic and programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.
- Secure - Execution of every java program is under the control of the JVM. JVM can contain the program and prevent it from generating side effects outside of the system.
How to install Java on Linux environment?
Java installation:Download Java SE Development Kit 8 RPM from the
link.
Install the downloaded RPM by running linux command
# Change current user to root user.
$ su -
# installs RPM in fedora, here /home/user dir is the rpm file downloaded location.
# rpm -Uvh /home/user/jdk-8u144-linux-x64.rpm
JDK installer for different environments like windows, Mac OS and Solaris can be downloaded in
link
Java Program Example:
// Sample Java code
public class Example {
public static void main(String []args) {
System.out.println("Welcome!");
}
}
How to compile and run java program?
c:\Java_code> javac Example.java
C:\Java_code> java Example
Welcome!
Javac compiler translates Example.java file into Example.class file that contains the bytecode version of the program. Example.class file cannot be directly executed.
To execute the Example.class, must use the java interpreter (java command). Java command interprets and executes the compiled java code.
What is Java history?
Originally developed by James Gosling at Sun Microsystems(which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform
What does Java compiler?
Create the java program in .java file and then compile the program using javac command.
Compiler checks program against the java language syntax rules, then converts into bytecode in .class files. Bytecode is a set of instructions targeted to run on a Java virtual machine (JVM).
Translating java program into bytecode makes it mush easier to run a program in a wide varity of environments.
Java compiler writes out instruction(bytecode) is suitable for CPU processor.
What is Java Platform?
A platform is the hardware or software environment in which a program runs. Java platform is a software-only platform that runs on top of other hardware-based platforms.
Two components:
- Java Virtual Machine (JVM): This is Virtual Machine, base for the Java platform and is ported onto various hardware-based platforms. At runtime, JVM interprets .class files and executes the program's instructions on the native hardware platform where JVM runs.
JVM is a software written specific to any particular platform. only JVM needs to be implemented for each platform
- Java Application Programming Interface (API): API is a large collection of predefined software components and grouped into libraries of classes and interfaces. this libraries are also called packages.
What is Garbage Collector in java?
Java supports implicit memory management and it is one of the important features in java.
Java code creates an object instance at runtime, the JVM automatically allocates memory for that object from the heap. Java garbage collector runs in the background, keeping track of which objects are no longer needs. and cleans memory from objects which will not be needed.
What is Java Development Kit?
JDK contains compiler, other tools and complete class library of prebuilt utilities that is used for most common application development tasks.
What is Java Runtime Environment?
JRE contains JVM, libraries, and components that are required to run java programs.
JRE is available for multiple platforms.
What is just-in-time compiler?
Compilation is done during execution of a program at run time rather than prior to execution.
Component of the JRE and improves the performance of Java code at run time.
JIT compiler is enabled by default, and is activated when a Java method is called and compiles the bytecodes of that method into native machine code.
« Previous
Next »
Java Programming Language Blog