Introduction to the Java Programming Language
Introduction to the Java Programming Language
Want to learn more about the Java programming language? Click here for a guide to Java, including history, features, the difference between C and C++, and more!
Join the DZone community and get the full member experience.Join For Free
Introduction to Java Programming Language
Java is a general-purpose, object-oriented programming language designed for the development of software for consumer electronic devices, such as TVs, VCRs, toasters, etc.
Java is a platform neutral language, which means that it is not tied to any particular hardware or operating system. It guarantees users to ‘write once, run anywhere.' The Java language is supported by almost every operating system, such as Sun Solaris, RedHat, Windows, etc.
The Java programming language was developed by Sun Microsystems of the USA in 1991, it was originally called Oak by James Gosling, who was one of the inventors of the language. The main goal for the developers was to make the language highly reliable, portable and simple.
The team for the development of Java language included Patrick Naughton, who discovered that the existing languages such as C and C++ had some major drawbacks in terms of reliability and portability. They modeled the new language Java on C and C++, while removing some features that they considered constraints. This made Java a really simple, portable, and powerful language. To learn Java basics, let’s revise the Java syntax.
The History of Java
There is a chronicle of events that occurred during the course of development of the Java language.
- 1990: A team of Sun Microsystems programmers decided to develop a special software to manipulate consumer electronic devices. The team headed by James Gosling.
- 1991: The team studied various languages present at that time, viz., C, and C++, and announced the new language to be “Oak.”
- 1992: The team at Sun, known as the Green Project, demonstrated the application of their new language, for example, to control a list of home appliances using a hand device with the tiny touchscreen.
- 1993: The World Wide Web came to the Internet and transformed the text-based Internet into a graphical, rich environment. The Green Project team came up with an idea of developing Web applets (tiny programs) that could run on all types of computers connected to the Internet.
- 1994: The team developed a web browser called “HotJava” to locate and run applet programs on the Internet. This made it immensely popular amongst Internet users.
- 1995: Oak was renamed as “Java,” due to some legal snags. Java is the name and not an acronym.
- 1996: Java programming was established as the leader for Internet programming and also as a general-purpose, object-oriented programming language. Sun released the Java Development Kit 1.0.
- 1997: Sun releases the Java Development Kit 1.1 (JDK 1.1)
- 1998: Sun releases Java 2 with version 1.2 of the Software Development Kit (SD K 1.2)
- 1999: Sun releases the Java 2 platform, Standard Edition (J2SE), and Enterprise Edition (J2EE)
- 2000: Sun releases J2SE with SDK 1.3.
- 2002: Sun releases J2SE with SDK 1.4.
- 2004: This marked the release of J2SE with JDK 5.0 (instead of JDK 1.5), known as J2SE 5.0.
- 2006- Sun releases Java SE 6.
- 2011: Sun releases Java SE 7.
- 2014: Sun releases Java SE 8.
- 2017: Sun releases Java SE 9.
Features of Java Programming
The main goal was to design a language that could offer solutions to problems encountered in modern programming. The goal was for the language to be reliable, portable, and distributed, and at the same time, it needed to be simple, compact, and interactive.
Compiled and Interpreted
Java language combines both of these approaches, thus making Java a two-stage system. This approach was never offered before, as any language before was either compiled or interpreted.
Firstly, the Java compiler translates source code into bytecode instructions; bytecodes are not machine instructions.
Secondly, the Java interpreter generates machine code that can be directly executed by the machine that is running the Java program.
Independent and Portable
Java programs can be easily moved from one system to another, anywhere and anytime. With changes or an upgrade in the operating system, processors and system resources will not force any changes in Java programs.
Java programming ensures portability in two ways. Firstly, Java compiler generates bytecode instructions that can be implemented on any machine, and secondly, the size of the primitive data types are machine independent.
Almost everything in Java language is an object, which makes it a true object-oriented language. All program code and data reside within objects and classes. Java comes with an extensive set of classes that are arranged in packages, which can be used in program inheritance.
Robust and Secure
Java provides many safeguards to ensure reliable code. It has strict run-time, checking for data types. It is designed like a garbage collected language, i.e., it captures series errors and eliminates any risk of crashing the system.
Java systems verify all the memory access and, thus, ensure that no virus is communicated with an applet.
Java programming facilitates both the sharing of data and programs. Java applications can open and access remote objects on the Internet as easily as on any local system.
Simple, Small, and Familiar
Java is a simplified version of C++, which is why it is familiar and yet different as it eliminates all the redundant and unreliable code. For example, Java does not use pointers, preprocessor header files, and many others. It also eliminates operator overloading and multiple inheritances in Java.
Multithreaded and Interactive
Multithreaded means handling different tasks simultaneously. Java language supports multithreaded programs, which means that we need not have to wait for one task to finish for another to start. This feature of Java greatly improves the interactive performance of graphical applications.
Java programming performance is very impressive, considering the fact that is an interpreted language, mainly because of the bytecodes. Java architecture is designed to reduce overheads.
Dynamic and Extensible
Java is a dynamic language; it is capable of dynamically linking in new class libraries, methods, and objects. It can also determine the type of class through a query.
Ease of Development
Java 2 standard edition (J2SE) 5.0 supports features such as Generics, Enhanced for loop, Autoboxing or unboxing, Typesafe enums, varargs, Static import, and Annotation. These Java features make it easy for Java programmers by shifting the responsibility of creating the reusable code to the compiler, and also, the resulting code is free from bugs.
Scalability and Performance
J2SE 5.0 improves the startup time and reduces the amount of memory used in the Java 2 runtime environment. Learn more features of Java here.
Comparison: C Vs. Java Vs. C++
C Vs. Java
The major difference between C and Java is that Java is an object-oriented language and has a mechanism to define classes and objects in Java. The features of C that are not included in Java are:
- No unique statement keywords of C size and typedef
- No data types, such as
- Java does not define the type modifier keywords, such as
- No support for the
- Non-availability of preprocessor
- Java requires that the function with no argument must be declared with empty parenthesis and with the void keyword.
- New Java operators, such as
- Java programming has labeled break and continue statements.
Java Vs. C++
The main difference between C++ and Java is that Java is a true object-oriented language while C++ just adds an object-oriented extension to C. The increment operator in C++ indicates the same thing.
The features listed below are intentionally omitted from Java to make it better.
- No support for operator overloading.
- No template classes as in C++.
- A new feature called “interface” in Java programming that does not support multiple inheritances.
- Java language does not support global variables.
- Java uses a
finalize()function instead of the
- There are no header files in Java programming.
Java Language and the Internet
Java is often called the "Internet language" because the first application program written in Java was HotJava, a web browser used to run applets on the Internet. Internet users can use Java to create applets and run them locally using HotJava. A Java-enabled browser to download an applet located anywhere on the Internet can also be used.
Java applets have made the Internet a true extension of the storage system on local computers. Internet users can also set up their websites containing Java applets that could be used by remote users.
Java Programming and World Wide Web
World Wide Web (www) is an information retrieval system where any information or file is identified as Uniform source Locators (URLs) and are interlinked via hypertext links. WWW can be accessed with the help of internet.
Internet and Java programming both had the same philosophy, and thus, they were incorporated with each other easily. Java made it possible for the World Wide Web to support animation, graphics, games, and a wide range of special effects.
To communicate with any web page, Java uses APPLETs. The steps involved are:
- The user requests for a hyperlink document to remote computer’s web server. (a web server receives, processes, and sends the requested document)
- The document contains the APPLET tag, which identifies the applet.
- Java source code file compiles the bytecode for that applet, which is then transferred to user’s computer.
- The browser is enabled by Java and then interprets the bytecode and provides the output.
Java Support Systems
The operations of Java and Java-enabled browsers on the Internet require a variety of support systems, namely:
- Internet Connection
- Web server
- Web Browser
- HTML— a language for creating hypertext for the web
- APPLET tag
- Java code
- Proxy Server — an intermediate server between the requesting client workstation and the original server
- Mail Server
The Java Environment
The Java environment includes a large number of Java development tools and Java classes and methods.
The Java development tools are part of the system known as the Java Development Kit (JDK), and the classes and the methods in Java are a part of the Java Standard Library (JSL), also known as the Application Programming Interface (API).
Java Development Kit (JDK)
The Java Development Kit includes:
- appletviewer (for viewing Java applets)
- javac ( Java compiler)
- java ( Java interpreter )
- javap ( Java disassembler )
- javah ( for C header files)
- javadoc ( for creating HTML files )
- jdb ( Java debugger )
Application Programming Interface
The Java Standard Library includes classes and packages, some most commonly used packages are the Language Support Packages. This is a collection of Java classes and methods required for implementing basic features of Java.
- Utility Package — To provide Java utility functions
- Input/output Package — For Java input/output manipulation
- Networking Package — For communicating via the Internet
- AWT Package — The abstract window toolkit package contains classes that implement a platform-independent, graphical user interface.
- Applet Package — this allows us to create Java applets.
Java Runtime Environment
The java Runtime Environment facilitates the execution of Java programs, comprising the Java Virtual Machine (JVM). The JVM interprets the intermediate Java bytecode and generates the desired output.
- Runtime class libraries — These are a set of core Java class libraries for execution of the Java program.
- User interface toolkits — These are used for interaction with the Java application program.
- Deployment technologies
1) Java plugin — This enables the execution of a Java applet.
Constructs are basically reserved keywords in any language, which cannot be used in rest of the programs, i.e., a name of variables in Java, class, or method. Java has around 50 such words, they include:
Finally, In this Java guide, we learned about the history of Java programming language, important Java features, how Java is different from C and C++, how it is incorporated in World Wide Web with help of Web browsers, and the environment required for running Java applications. Hope this helps. Let us know what you think in the coments below!
Published at DZone with permission of Rinu Gour . See the original article here.
Opinions expressed by DZone contributors are their own.