Introduction to Java
Java is a general-purpose, object-oriented programming language and computing platform first released by Sun Microsystems in May 1995. It was developed by James Gosling and his team. After Sun Microsystems was acquired by Oracle Corporation, Java became an Oracle product.
Java is divided into three editions:
- JavaSE (Java Platform, Standard Edition)
- JavaEE (Java Platform, Enterprise Edition)
- JavaME (Java Platform, Micro Edition)
In June 2005, at the JavaOne conference, Sun Microsystems announced the release of Java SE 6. By this time, the various editions of Java had been renamed to remove the "2": J2EE became Java EE, J2SE became Java SE, and J2ME became Java ME.
Key Features
-
Java is Simple:
Java's syntax is similar to C and C++, making it easy for most programmers to learn and use. Java eliminates difficult-to-understand features like operator overloading, multiple inheritance, and automatic type casting found in C++. Instead of pointers, Java uses references and includes automatic memory management, relieving programmers from manual memory management.
-
Java is Object-Oriented:
Java supports features like classes, interfaces, and inheritance. It only supports single inheritance between classes but allows multiple inheritance between interfaces. Java also supports the implementation mechanism between classes and interfaces using the 'implements' keyword. Unlike C++, Java fully supports dynamic binding, making it a purely object-oriented language.
-
Java is Distributed:
Java supports the development of Internet applications and provides a network API (java.net) that includes classes for network programming, such as URL, URLConnection, Socket, and ServerSocket. Java's Remote Method Invocation (RMI) mechanism is also a key tool for developing distributed applications.
-
Java is Robust:
Java's strong type system, exception handling, and automatic garbage collection are key to its robustness. The decision to omit pointers was wise, and Java's security mechanisms enhance its robustness.
-
Java is Secure:
Java is often used in network environments and provides security features to prevent malicious code attacks. It includes a security mechanism for downloaded classes (ClassLoader), bytecode verification, and a security manager to set up security guards.
-
Java is Architecture-Neutral:
Java programs are compiled into architecture-neutral bytecode, which can run on any system that implements the Java platform. This approach is ideal for heterogeneous network environments and software distribution.
-
Java is Portable:
Java's portability is due to its architecture-neutral design and strict specification of data type lengths. The Java system itself is highly portable, with the Java compiler implemented in Java and the runtime environment in ANSI C.
-
Java is Interpreted:
Java programs are compiled into bytecode and then interpreted by the Java interpreter at runtime. Classes required during execution are loaded into the runtime environment during the linking phase.
-
Java is High-Performance:
Compared to interpreted scripting languages, Java offers high performance. With the development of Just-In-Time (JIT) compilation technology, Java's performance has approached that of C++.
-
Java is Multithreaded: In Java, a thread is a special object that must be created by the Thread class or its subclasses. There are typically two ways to create a thread: one is to use a constructor of the form Thread(Runnable) to wrap an object that implements the Runnable interface into a thread; the other is to derive a subclass from the Thread class and override the run method, where an object created by this subclass is a thread. It is worth noting that the Thread class itself has implemented the Runnable interface, so every thread has its run method, which contains the code that the thread is intended to execute. The activity of a thread is controlled by a set of methods. Java supports the concurrent execution of multiple threads and provides synchronization mechanisms (with the keyword synchronized) between threads.
Java is Dynamic:
One of the design goals of Java is to adapt to dynamically changing environments. Java programs can dynamically load the classes they need into the runtime environment, and classes can also be loaded over the network, which is beneficial for software upgrades. Additionally, Java classes have a runtime representation and can perform runtime type checks.
Development History
- May 23, 1995: Java was born.
- January 1996: The first JDK-JDK1.0 was released.
- April 1996: The top 10 operating system suppliers announced they would embed Java technology in their products.
- September 1996: About 83,000 web pages used Java technology for creation.
- February 18, 1997: JDK1.1 was released.
- April 2, 1997: The JavaOne conference was held, with over 10,000 participants, setting a record for global同类 conferences.
- September 1997: The JavaDeveloperConnection community had over 100,000 members.
- February 1998: JDK1.1 was downloaded over 2,000,000 times.
- December 8, 1998: The Java 2 enterprise platform J2EE was released.
- June 1999: SUN Microsystems released three versions of Java: Standard Edition (JavaSE, formerly J2SE), Enterprise Edition (JavaEE, formerly J2EE), and Micro Edition (JavaME, formerly J2ME).
- May 8, 2000: JDK1.3 was released.
- May 29, 2000: JDK1.4 was released.
- June 5, 2001: NOKIA announced it would sell 100 million Java-enabled phones by 2003.
- September 24, 2001: J2EE1.3 was released.
- February 26, 2002: J2SE1.4 was released, significantly enhancing Java's computing power.
- September 30, 2004: J2SE1.5 was released, marking another milestone in the development of Java. To emphasize its importance, J2SE1.5 was renamed Java SE 5.0.
- June 2005: The JavaOne conference was held, and SUN Microsystems unveiled Java SE 6. By this time, Java's various editions had been renamed to remove the digit "2": J2EE became Java EE, J2SE became Java SE, and J2ME became Java ME.
- December 2006: SUN Microsystems released JRE6.0.
- April 20, 2009: Oracle acquired Sun for $7.4 billion, gaining the rights to Java.
- November 2010: Apache threatened to withdraw from the JCP due to Oracle's unfriendly stance towards the Java community.
- July 28, 2011: Oracle released the official version of Java 7.0.
- March 18, 2014: Oracle released Java SE 8.
- September 21, 2017: Oracle released Java SE 9.
- March 21, 2018: Oracle released Java SE 10.
- September 25, 2018: Java SE 11 was released.
- March 20, 2019: Java SE 12 was released.
Java Development Tools
Java requires at least 1GB of system memory. Other tools include:
- Linux, Mac OS, Windows 95/98/2000/XP, WIN 7/8 systems.
- Java JDK 7, 8...
- vscode editor or other editors. IDE: Eclipse, IntelliJ IDEA, NetBeans, etc.
After installing the above tools, we can output the first Java program "Hello World!"
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
In the next section, we will introduce how to configure the Java development environment.