Week 1-2 - Java Language.pdf
Document Details
Uploaded by ThinnerRainbow
Ama International University
Tags
Full Transcript
Object Oriented Programming – JAVA LANGUAGE JAVA LANGUAGE History of Java Programming Language Java is an Object-Oriented programming language developed by James Gosling in the early 1990s. Th...
Object Oriented Programming – JAVA LANGUAGE JAVA LANGUAGE History of Java Programming Language Java is an Object-Oriented programming language developed by James Gosling in the early 1990s. The team initiated this project to develop a language for digital devices such as set-top boxes, television, etc. Originally C++ was considered to be used in the project but the idea was rejected for several reasons(For instance C++ required more memory). Gosling endeavoured to alter and expand C++ however before long surrendered that for making another stage called Green. James Gosling and his team called their project “Greentalk” and its file extension was.gt and later became to known as “OAK”. Why “Oak”? The name Oak was used by Gosling after an oak tree that remained outside his office. Also, Oak is an image of solidarity and picked as a national tree of numerous nations like the U.S.A., France, Germany, Romania, etc. But they had to later rename it as “JAVA” as it was already a trademark by Oak Technologies. “JAVA” Gosling and his team did a brainstorm session and after the session, they came up with several names such as JAVA, DNA, SILK, RUBY, etc. Java name was decided after much discussion since it was so unique. The name Java originates from a sort of espresso bean, Java. Gosling came up with this name while having a coffee near his office. Java was created on the principles like Robust, Portable, Platform Independent, High Performance, Multithread, etc. and was called one of the Ten Best Products of 1995 by the TIME MAGAZINE. Currently, Java is used in internet programming, mobile devices, games, e-business solutions, etc. The Java language has experienced a few changes since JDK 1.0 just as various augmentations of classes and packages to the standard library. In Addition to the language changes, considerably more sensational changes have been made to the Java Class Library throughout the years, which has developed from a couple of hundred classes in JDK 1.0 to more than three thousand in J2SE 5. 1|P age Object Oriented Programming – JAVA LANGUAGE History of various Java versions: RELEASE VERSION DATE MAJOR CHANGES JDK Beta 1995 January The Very first version was released on January 23, 1996. The JDK 1.0 1996 principal stable variant, JDK 1.0.2, is called Java 1. Was released on February 19, 1997. There were many additions in JDK 1.1 as compared to version 1.0 such as A broad retooling of the AWT occasion show February Inner classes added to the language JavaBeans JDK 1.1 1997 JDBC RMI “Play area” was the codename which was given to this form and was released on 8th December 1998. Its real expansion included: strictfp keyword the Swing graphical API was coordinated into the centre classes December Sun’s JVM was outfitted with a JIT compiler out of the blue Java module J2SE 1.2 1998 Java IDL, an IDL usage for CORBA interoperability Collections system Codename- “KESTREL” Release Date- 8th May 2000 Additions: HotSpot JVM included Java Naming and Directory Interface JPDA J2SE 1.3 May 2000 JavaSound Synthetic proxy classes 2|P age Object Oriented Programming – JAVA LANGUAGE RELEASE VERSION DATE MAJOR CHANGES Codename- “Merlin” Release Date- 6th February 2002 Additions: Library improvements Regular expressions modelled after Perl regular expressions The image I/O API for reading and writing images in formats like JPEG and PNG Integrated XML parser and XSLT processor (JAXP) (specified in JSR 5 and JSR 63) February Preferences API (java.util.prefs) Public Support and security updates for this version ended in J2SE 1.4 2002 October 2008. Codename- “Tiger” Release Date- “30th September 2004” Originally numbered as 1.5 which is still used as its internal version. Added several new language features such as: September for-each loop Generics J2SE 5.0 2004 Autoboxing Var-args Codename- “Mustang” Released Date- 11th December 2006 Packaged with a database supervisor and encourages the utilization of scripting languages with the JVM. Replaced the name J2SE with ava SE and dropped the.0 from the version number. Additions: JAVA SE December Upgrade of JAXB to version 2.0: Including integration of a StAX parser. 6 2006 Support for pluggable annotations (JSR 269). JDBC 4.0 support (JSR 221) 3|P age Object Oriented Programming – JAVA LANGUAGE RELEASE VERSION DATE MAJOR CHANGES Codename- “Dolphin” Release Date- 7th July 2011 Added small language changes including strings in the switch. The JVM was extended with support for dynamic languages. Additions: JAVA SE Compressed 64-bit pointers. 7 July 2011 Binary Integer Literals. Upstream updates to XML and Unicode. Released Date- 18th March 2014 JAVA SE Language level support for lambda expressions and default 8 March 2014 methods and a new date and time API inspired by Joda Time. Release Date: 21st September 2017 Project Jigsaw: designing and implementing a standard, a module JAVA SE September system for the Java SE platform, and to apply that system to the 9 2017 platform itself and the JDK. Released Date- 20th March Addition: Additional Unicode language-tag extensions Root certificates JAVA SE Thread-local handshakes Heap allocation on alternative memory devices 10 March 2018 Remove the native-header generation tool – javah. Consolidate the JDK forest into a single repository. Released Date- 25th September, 2018 JAVA SE September Additions- 11 2018 Dynamic class-file constants 4|P age Object Oriented Programming – JAVA LANGUAGE RELEASE VERSION DATE MAJOR CHANGES Epsilon: a no-op garbage collector The local-variable syntax for lambda parameters Low-overhead heap profiling HTTP client (standard) Transport Layer Security (TLS) 1.3 Flight recorder Released Date- 19th March 2019 Additions- Shenandoah: A Low-Pause-Time Garbage Collector (Experimental) Microbenchmark Suite JAVA SE Switch Expressions (Preview) JVM Constants API 12 March 2019 One AArch64 Port, Not Two Default CDS Archives JAVA TECHNOLOGY The Java Development Kit (JDK) is one of three core technology packages used in Java programming, along with the JVM (Java Virtual Machine) and the JRE (Java Runtime Environment). It's important to differentiate between these three technologies, as well as understanding how they're connected: The JVM is the Java platform component that executes programs. The JRE is the on-disk part of Java that creates the JVM. The JDK allows developers to create Java programs that can be executed and run by the JVM and JRE. Developers new to Java often confuse the Java Development Kit and the Java Runtime Environment. The distinction is that the JDK is a package of tools for developing Java-based software, whereas the JRE is a package of tools for running Java code. The JRE can be used as a standalone component to simply run Java programs, but it's also part of the JDK. The JDK requires a JRE because running Java programs is part of developing them. 5|P age Object Oriented Programming – JAVA LANGUAGE Figure 1 shows how the JDK fits into the Java application development lifecycle. Used to JDK Create a Java JVM Program Compiled Java Java Program JRE Program Run inside Used to execute Java Program Figure 1. High-level view of the JDK Just as we did with my recent introduction to the Java Virtual Machine, let's consider the technical and everyday definitions of the JDK: Technical definition: The JDK is an implementation of the Java platform specification, including compiler and class libraries. Everyday definition: The JDK is a software package you download in order to create Java-based applications. The JDK & the Java compiler In addition to the JRE, which is the environment used to run Java applications, every JDK contains a Java compiler. The compiler is the software program capable of taking raw.java files--which are plain text--and rendering them into executable.class files. We'll see the compiler in action soon. First, I'll show you how to download and setup a JDK in your development environment. Features of Java The primary objective of Java programming language creation was to make it portable, simple and secure programming language. Apart from this, there are also some excellent features which play an important role in the popularity of this language. The features of Java are also known as java buzzwords. 6|P age Object Oriented Programming – JAVA LANGUAGE A list of most important features of Java language is given below. Figure 2. Features of Java 1. Simple 2. Object-Oriented 3. Portable 4. Platform independent 5. Secured 6. Robust 7. Architecture neutral 8. Interpreted 9. High Performance 10. Multithreaded 11. Distributed 12. Dynamic Simple Java is very easy to learn, and its syntax is simple, clean and easy to understand. According to Sun, Java language is a simple programming language because: Java syntax is based on C++ (so easier for programmers to learn it after C++). Java has removed many complicated and rarely-used features, for example, explicit pointers, operator overloading, etc. 7|P age Object Oriented Programming – JAVA LANGUAGE There is no need to remove unreferenced objects because there is an Automatic Garbage Collection in Java. Object-oriented Java is an object-oriented programming language. Everything in Java is an object. Object-oriented means we organize our software as a combination of different types of objects that incorporates both data and behavior. Object-oriented programming (OOPs) is a methodology that simplifies software development and maintenance by providing some rules. Basic concepts of OOPs are: 1. Object 2. Class 3. Inheritance 4. Polymorphism 5. Abstraction 6. Encapsulation Platform Independent Figure 3. Platform Independent 8|P age Object Oriented Programming – JAVA LANGUAGE Java is platform independent because it is different from other languages like C, C++, etc. which are compiled into platform specific machines while Java is a write once, run anywhere language. A platform is the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides a software-based platform. The Java platform differs from most other platforms in the sense that it is a software- based platform that runs on the top of other hardware-based platforms. It has two components: 1. Runtime Environment 2. API(Application Programming Interface) Java code can be run on multiple platforms, for example, Windows, Linux, Sun Solaris, Mac/OS, etc. Java code is compiled by the compiler and converted into bytecode. This bytecode is a platform-independent code because it can be run on multiple platforms, i.e., Write Once and Run Anywhere(WORA). Secured Java is best known for its security. With Java, we can develop virus-free systems. Java is secured because: No explicit pointer Java Programs run inside a virtual machine sandbox Figure 4. Virtual Machine Sandbox 9|P age Object Oriented Programming – JAVA LANGUAGE Classloader: Classloader in Java is a part of the Java Runtime Environment(JRE) which is used to load Java classes into the Java Virtual Machine dynamically. It adds security by separating the package for the classes of the local file system from those that are imported from network sources. Bytecode Verifier: It checks the code fragments for illegal code that can violate access right to objects. Security Manager: It determines what resources a class can access such as reading and writing to the local disk. Java language provides these securities by default. Some security can also be provided by an application developer explicitly through SSL, JAAS, Cryptography, etc. Robust Robust simply means strong. Java is robust because: It uses strong memory management. There is a lack of pointers that avoids security problems. There is automatic garbage collection in java which runs on the Java Virtual Machine to get rid of objects which are not being used by a Java application anymore. There are exception handling and the type checking mechanism in Java. All these points make Java robust. Architecture-neutral Java is architecture neutral because there are no implementation dependent features, for example, the size of primitive types is fixed. In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes of memory for 64-bit architecture. However, it occupies 4 bytes of memory for both 32 and 64-bit architectures in Java. Portable Java is portable because it facilitates you to carry the Java bytecode to any platform. It doesn't require any implementation. 10 | P a g e Object Oriented Programming – JAVA LANGUAGE High-performance Java is faster than other traditional interpreted programming languages because Java bytecode is "close" to native code. It is still a little bit slower than a compiled language (e.g., C++). Java is an interpreted language that is why it is slower than compiled languages, e.g., C, C++, etc. Distributed Java is distributed because it facilitates users to create distributed applications in Java. RMI and EJB are used for creating distributed applications. This feature of Java makes us able to access files by calling the methods from any machine on the internet. Multi-threaded A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi-threading is that it doesn't occupy memory for each thread. It shares a common memory area. Threads are important for multi-media, Web applications, etc. Dynamic Java is a dynamic language. It supports dynamic loading of classes. It means classes are loaded on demand. It also supports functions from its native languages, i.e., C and C++. Java supports dynamic compilation and automatic memory management (garbage collection). HELLO WORLD APPLICATION 1. Write the source code: HelloWorld.java public class HelloWorld{ public static void main( String args[] ){ System.out.println(“Hello world”); } } 11 | P a g e Object Oriented Programming – JAVA LANGUAGE Figure 5. Hello World Program 2. Compile: javac HelloWorld.java 3. Run: java HelloWorld Figure 6. Hello World Write, Compile, Run Sources Bhatnagar G. (n.d.). The Complete History of Java Programming Language https://www.geeksforgeeks.org/the-complete-history-of-java-programming-language/ Features of Java https://www.javatpoint.com/features-of-java Tyson, M. (2018). What is Java? https://www.javaworld.com/article/3296360/what-is-the-jdk-introduction-to-the-java- development-kit.html History of Java Programming Languages https://www.freejavaguide.com/history.html 12 | P a g e