# Java Programs
➤ Introduction to Java
➤ Java Editions & Concepts
➤ JDK JRE JVM JIT in Java
➤ How to Run Java program
➤ Java Hello World program
➤ How to set the Java path
➤ Classpath Environment
➤ Tokens in Java Language
➤ List of Java Keywords
➤ Identifiers in Java
➤ Data types in Java
➤ Float & double in Java
➤ Literals in Java
➤ Escape Sequence In Java
➤ Unicode character set
➤ String data type in Java
➤ Arithmetic operators in Java
➤ Increment and Decrement
➤ Comments in Java
➤ Java Naming Conventions
➤ Static Import in Java
Introduction to Java Programming. Here we will learn what is Java, the history of Java, Java version history, features of java, and the applications of Java.
Java is a simple, secured, high level, platform-independent, multithread, Object-oriented programming language.
It’s one of the most popular and widely used programming language, platform, and technology. Java is not only a language it is also a platform and technology.
A platform is an environment that helps to develop and run programs written in any programming language. Java has its own software-based platform called JVM (Java virtual machine) to execute the programs. Apart from Java, the other programming languages that use JVM are Kotlin (used for developing Android applications), Scala, Jython, JRuby, Groovy, and many more.
Java is a programming language because it provides its own syntaxes and semantics for developing new programs. It is a platform because it provides its own execution environment called JVM. Java program is not executed directly by the operating system, it is executed by JVM. It is technology because it provides pre-defined rich set of API (library) for fast and easy development.
Java was developed by SUN microsystems, Inc. (Sun for short) for developing internet-based, high performance, distributed, dynamically extensible applications. Oracle Corporation acquired Sun microsystems on January 27, 2010; Now, Java is owned by Oracle Corporation.
Java was invented by James Gosling. He with his team of 11 members invented Java language in SUN microsystems.
History of Java
The Java platform was initially developed to address the problems of building software for network consumer electronic devices. It was designed to support multiple host architectures and to allow secure delivery of software components.
The language was initially called OAK after an oak tree that stood outside Gosling’s Office. They were unable to register this programming language with the name OAK because already some other product was already registered with the same name. Later the project went by the name Green and was finally renamed as Java, from Java coffee. Java Arabica coffee is grown on the island of Java in Indonesia.
Earlier C++ was the language that was object-oriented but it has many problems like it is platform dependent. Gosling designed Java with a C/C++ style that system and application programmers would find familiar.
There is no abbreviation or technical meaning for Java. Java specifically does not have any meaning rather it refers to the hot, aromatic drink Coffee. This is the reason Java programming language icon is the coffee cup.
Introduction to Java: Java Version
SUN microsystems released the public implementation as Java1.0 on January 23, 1996. It promised “write once, run anywhere” (WORA) on popular platforms such as Windows operating system, Linux, Mac OS. Java first version was released as 1.0 followed by 1.1, 1.2, 1.3, 1.4 || 5.0 (1.5), 6(1.6), 7(1.7), 8(1.8) || 9, 10, 11, 12, 13
|Java version||Release date|
|JDK 1.0||January 23, 1996|
|JDK 1.1||February 19, 1997|
|J2SE 1.2||December 8, 1998|
|J2SE 1.3||May 8, 2000|
|J2SE 1.4||February 6, 2002|
|J2SE 5.0||September 30, 2004|
|Java SE 6||December 11, 2006|
|Java SE 7||July 28, 2011|
|Java SE 8||March 18, 2014|
|Java SE 9||September 21, 2017|
|Java SE 10||March 20, 2018|
|Java SE 11||September 25, 2018|
|Java SE 12||March 19, 2019|
|Java SE 13||September 17, 2019|
|Java SE 14||March 17, 2020|
|Java SE 15||September 15, 2020|
|Java SE 16||March 2021|
|Java SE 17||September 2021 (Upcoming)|
The acquisition of Sun Microsystems by Oracle Corporation was completed on January 27, 2010. Oracle Corporation is the current owner of the official implementation of the Java SE platform.
Up to the Java 9 version, every new version was released either for 2/3/4 years once. Due to this, the Java language was unable to support the latest requirement and latest technologies for developing the project. Hence after the Java9 version, from the Java10 version onwards Oracle corporation has introduced 6-Months release cadence. It means after every 6 months we will get a new version of Java with the latest features to support new technologies and requirements for the projects. In this 6-Month release cadence, in every new version, we get 5-6 new features. So, learning and using these features in our projects is easy for us.
Among these versions only Java 8 and Java 11 versions are LTS (Long Term Support) versions, remaining all other versions are supported only up to release of the next version. You will see most of the Java programmers are working with LTS versions only.
|Java Version (LTS)||Extended Support Until|
|Java SE 8||December 2030|
|Java SE 11||September 2026|
|Java SE 17||N/A|
The latest version of JAVA is Java SE 15 which was released in 15 Sep 2020, but the latest long term support (LTS) version is Java SE 11.
Features of Java
Java came into the market with the main 10 following features.
- Architectural natural
- High performance
- Dynamic natural
Let us understand all these features one by one.
Java is a very simple programming language both from learning and developing points of view.
From the learning point of view, Java is simple because it has a similar syntax from C/C++ programming languages. Java omits many features that can make Java language complex, confuse, and unsafe. So, Java doesn’t have multiple inheritance, structure, union, template, operator overloading, explicit memory allocation e.t.c. Java also doesn’t support pointer creation in a program, But Java software has pointer internally.
From the development point of view, Java is simple because it provides a rich set of pre-defined libraries (API). Using these huge pre-defined libraries API we don’t need to write more code. Hence development becomes easy for us.
Java is secure from code and data point of view.
Java is secure from the code point of view because Java compiled code doesn’t execute directly. Before its execution, the Bytecode verifier verifies byte code. If there will be any malicious code or virus then execution will be terminated.
From the data point of view, it is secure because it has accessibility modifiers and incapsulation. Using access modifiers ( private, public, default and protected ) we can hide the direct access of the data, available in one program to another program. Or, we can provide data access to another program via a method that is incapsulation.
Java is robust, it means reliable. It is strong in type checking and terminating function safely. Java is strictly typed checking language, it does not allow to store high range value in a lesser range variable. For example, if we write int x = 8.2; then the compiler will throw an error. The variable x is of int data type and 8.2 is of the double data type. The double data type has a greater range value than an int data type.
The main features that make it robust are Exception handling, garbage collection, and memory allocation.3
Java terminates function safely. It guarantees fail-safe by using exception handling mechanism. With exception handling mechanisms we can stop terminating program execution and save the results. When execution of a program failed then the program doesn’t terminate immediately and we don’t lose the value generated in the previous lines.
Java programs are portable. One Java program written in one computer can run in a different operating system. Java program is portable because its memory size is fixed across all operating systems and processors. Hence, we get the same result on all platforms. It can run in any operating system because of the platform-independency nature.
But when it came to C/C++ programming language then the size of data types is dependent on the compiler or you can say that the system architecture i.e. 32-bit compiler or 64-bit compiler. The size of data type int is 2 byte in 32-bit architecture and 4 bytes in 64-bit architecture. Another factor on which the size of data type depends is the compiler on which you perform any program i.e. In turbo c/c++ the size of int is 2 bytes but in the compiler like code blocks, dev c/c++ e.t.c is 4 bytes.
Java is a platform-independent language. Irrespective of other computer hardware, software devices, and operating systems Java programs can run in any computer and in any operating system because of Java virtual machines (JVM).
Java is an object-oriented programming language. Every program in Java develops around an object by using a concept called class. Every class-based programming language is an object-oriented programming (OOP) language.
Java is a multithreaded programming language. In Java, we can execute multiple tasks concurrently. Multithreading is one of the Java features, and it allows concurrent execution of two or more parts of a program for maximum utilization of CPU.
Due to multithread nature and JIT compiler, Java programs executed fast and give high performance. Java architecture is designed to reduce overheads.
Java is a distributed language. The Java program placed in one computer can be accessed via the network from another computer directly from a program. Objects on one Java virtual machine (JVM) can execute procedures on a remote JVM. Java can be used to create distributed applications, the EJB (Enterprise Java Beans) and RMI (Remote Method Invocation) are used for this purpose.
From memory and functionality point of view, Java is a dynamic programming language. Through the memory point of view, Java can allocate multiple copies of memory for the same variable at the execution time by using
new Keyword. Also from the functionality point of view Java is dynamic. Once we develope the project then we can add more features and modify existing features dynamically without modifying source code. It is possible because of the OOP concept, inheritance, and polymorphism.
- Byte coded:- Java program not compiled into machine language code like C, C++. Java program is compiled into a special instruction set called byte code.
- Interpreted:- In Java, to convert byte code to machine language code and further to execute this machine language code, inside JVM the interpreter used. Java program is executed by interpreter so, Java is called interpreted programming language.
- Garbage collecter:- Java is an automatic memory management programming language. In Java we need not destroy object memory, it is automatically destroyed by a special program called garbage collector.
- Open Source:- Java is open-source software. It is freely available to download. Its source code is available for programmers either for reading or modifying. Any third party company or programmer can suggest and add more functionalities to the software.
Applications of Java
Java is used from desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the internet. Java is used in every nook and corner. We use Java for developing different types of applications given below.
- Desktop applications. Example:- Calculator, Trader Console
- Web servers and applications servers
- Enterprise applications. Example:- bank applications.
- Interoperable applications. Example:- Facebook
- Mobile applications. Example:- Android apps
- Gaming applications
- Robotics application
- Database connections like Oracle database e.t.c.
Prerequisites to learn Java
There are no prerequisites to learn Java. Anyone can learn Java as the first programming language. There is no need to have knowledge of C/C++ programming languages. If you already know C/C++ programming language then it will be added advantages for you.
In the Introduction to Java, you got the basics of Java. At KnowProgram, you will get depth knowledge of Java. Just follow all these Java tutorials and practice Java programming examples for logical questions, after that you will have a strong base on Java programming language. And then you can easily learn Java technologies like JDBC (Java Database Connectivity), Servlet, and JSP ( for developing web/enterprise applications), Frameworks like Spring, Hibernate, web-services.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!