Java (Computer Programming Language)

Java is an object-oriented programming language, not only absorb the advantages of C++ language, but also abandon C++ difficult to understand multiple inheritance, Pointers and other concepts, so Java language has powerful and easy to use two characteristics. As a representative of static object-oriented programming languages, Java language has implemented object-oriented theory well, allowing programmers to do complex programming in an elegant way of thinking.

Java has the characteristics of simplicity, object-oriented, distributed, robustness, security, platform independence and portability, multi-threading, dynamic and so on. Java can be used to write desktop applications, Web applications, distributed systems and embedded system applications, etc.

The development course

In the 1990s, the advent of single-chip computing systems in the hardware world immediately attracted the attention of people in the automation field because they could make consumer electronics (TV set-top boxes, bread ovens, mobile phones, etc.) much smarter. To get ahead of the market, Sun formed a project called Green in 1991. Patrick, James Gosling, Mike Sheridan and a few other engineers worked on new technologies in a small studio on Dune Road in Menlo Park, California. Specializing in computer embedded applications in home appliances.

Because of the advantages of C++, the project’s researchers first considered writing programs in C++. But C++ programs are too complex and large for monolithic systems with extremely limited hardware resources. In addition, because of the variety of embedded processor chips used in consumer electronic products, how to write programs to run across platforms is also a problem. In order to solve the difficulties, they first focus on the development of language, assuming that a kind of simple structure, meets the needs of embedded application system hardware structure and formulate the corresponding specification, which defines the hardware platform of the binary system of machine code instructions (later to become “bytecode instruction system”), for after the success of the language development, There can be semiconductor chip manufacturers developing and producing such hardware platforms. To the design of the new language, Sun developers did not develop a whole new language, but according to the requirements of embedded software in c + +, in addition to stay in some of the c + + is not very practical and influence the composition of the security, and connecting with the real-time demand of the embedded system, developed a called object-oriented languages of Oak.

Due to the development of Oak language, still there is no running bytecode hardware platform, so in order to develop can undertake experimental study of the language, when they are on the basis of the existing hardware and software platform, according to the standard of their specified, using software built a platform, the entire system in addition to more simple than c + +, there is no big difference. In the summer of 1992, when Oak was developed, the researchers demonstrated the Green operating system, Oak’s programming language, libraries, and hardware to convince hardware manufacturers to use Oak for hardware chips. Hardware manufacturers, however, were not enthusiastic. They decided it was too risky to produce hardware without anyone knowing anything about Oak, so the Oak language was shelved for lack of hardware support.

In June/July 1994, after three days of discussions, the team decided to change the goal of the effort again, this time by applying the technology to the World Wide Web. They argue that with the advent of Mosaic, the Internet is evolving to the same highly interactive vision that they saw in cable networks. As a prototype, Patrick NORTON wrote WebRunner, a small web browser. [4]

In 1995, the Internet boom gave Oak its chance. In order to make the rigid, static web “flexible”, the industry needs software technology to develop programs that can spread over the network and run across platforms. Therefore, the world’s major IT enterprises have invested a large number of human, material and financial resources. This time, the Sun’s thought of the stalled long Oak, and review the written in the software test platform, because it is written according to according to the embedded system hardware platform system structure, so is very small, characteristic is suitable for the transmission system on the network, and Oak is also a kind of concise language, application is very small, Suitable for transmission over the network. Sun first introduced applets that could be embedded into web pages and carried over the web. It renamed Oak Java. (When it filed for a trademark, it discovered Oak was already in use, and after a series of names, eventually, Using Java words that the proposer accidentally mentioned over a cup of Java coffee). On May 23, Sun officially announced the Java and HotJava browsers at the Sun World conference. IBM, Apple, Digital, Adobe, HP, Oracle, Netscape, and Microsoft all shut down their development projects and raced to buy Licenses to use Java and develop Java platforms for their products. [5-6]

In January 1996, Sun released the first development kit for Java (JDK 1.0), which was an important milestone in the development of Java and marked the emergence of Java as an independent development tool. In September, about 83,000 web pages were created using Java technology. In October Sun released the first just-in-time (JIT) compiler for the Java platform.

In February 1997, JDK 1.1 was released, and within three weeks, it had been downloaded 220,000 times. On April 2, the Java One Conference was held with over 10,000 attendees, the largest conference of its kind in the world at the time. In September, the Java Developer Connection community surpassed 100,000 members.

The enterprise version of J2EE, the second generation of the Java platform, was released on December 8, 1998. In June 1999, Sun released three versions of the second generation of Java platform (abbreviated as Java2) : J2ME (Java2 Micro Edition), which is applied to mobile, wireless and limited resource environment; J2SE (Java 2 Standard Edition, Java 2 platform Standard Edition), applied to the desktop environment; J2EE (Java 2Enterprise Edition, enterprise Edition of the Java 2 platform) for Java-based application servers. The release of the Java 2 platform is one of the most important milestones in the development of Java, marking the beginning of the popularization of Java.

The HotSpot VIRTUAL machine was released on April 27, 1999. The HotSpot VIRTUAL machine was released as an add-on to JDK 1.2 and has since become the default virtual machine for all Sun JDK versions 1.3 and later [7].

JDK1.3, JDK1.4, and J2SE1.3 were released in May 2000 and gained industry standard support for Apple’s Mac OS X a few weeks later. On September 24, 2001, J2EE1.3 was released. On February 26, 2002, J2SE1.4 was released. Since then, Java’s computing power has improved dramatically, with nearly 62% more classes and interfaces than J2SE1.3. Among the new features are extensive XML support, secure Socket support (over SSL and TLS protocols), new I/OAPI, regular expressions, logging, and assertions. On September 30, 2004, J2SE1.5 was released, another milestone in the history of Java language development. In recognition of the release’s importance, J2SE 1.5 was renamed Java SE 5.0 (internal version 1.5.0) and codenamed “Tiger,” which contains the most significant update since the release of version 1.0 in 1996, These include generic support, automatic boxing of primitive types, improved loops, enumerated types, formatted I/O, and mutable parameters.

In June 2005, Sun announced Java SE 6 at the Java One Conference. At this point, various versions of Java have been renamed with the number 2 removed, such as J2EE to JavaEE, J2SE to JavaSE, and J2ME to JavaME.

On November 13, 2006, Sun, the inventor of Java technology, announced that it would release Java technology as free software. Sun releases the first source code for the standard version of the Java platform, and the executable source code for the Java Mini version. As of March 2007, all developers worldwide can make modifications to the Java source code [9].

In 2009, Oracle announced its acquisition of Sun [10]. 2010 James Gosling, one of the co-founders of the Java programming language, resigned from Oracle. In 2011, oracle held a global event to celebrate the launch of Java7, which was followed by its official release. In 2014, oracle released the official Java8 [11].

Programming development editor

The Java Development Kit (JDK), known as the Java Development Kit or Java Development tool, is a program Development environment for writing Java Applet small programs and applications. The JDK is the core of Java as a whole, with Java Runtime environs, Java tools, and Java apis in Java. Virtually any Java application server has some version of the JDK built in. The mainstream JDK is the JDK released by Sun Company. Besides Sun, many other companies and organizations have developed their own JDK, such as JDK developed by IBM Company, Jrocket developed by BEA Company, and JDK developed by GNU Organization [13].

In addition, the Java SE API subset and The Java virtual machine in the Java API class library can be collectively referred to as the Java Runtime Environment (JRE), which is the standard Environment supporting the running of Java programs [14].

The JRE is a runtime environment and the JDK is a development environment. So you need the JDK to write Java programs, and you need the JRE to run Java programs. The JDK already includes the JRE, so as long as the JDK is installed, you can edit Java programs and run them normally. However, because JDK contains a lot of non-runtime content and occupies a large space, it is not necessary to install JDK to run ordinary Java programs, but only need to install JRE [15].

Programming tools

Eclipse: An open source, Java-based, extensible development platform [16]. NetBeans: An open source Java integrated development environment for a variety of client and Web applications. IntelliJ IDEA: it has very good functions in automatic prompts, code analysis and so on. [17] MyEclipse: Commercial software developed by Genuitec, is a widely used Integrated Development environment for Java applications [18]. EditPlus: If Java’s compiler “Javac” and interpreter “Java” are correctly configured, Java programs can be compiled and executed directly using EditPlus [19].

Language features

1. Simplicity

Java looks designed to look a lot like C++, but in order to make the language small and familiar, the designers removed many of the features available in C++ that are rarely used by the average programmer. For example, Java does not support go to statements and instead provides break and continue statements and exception handling. Java also eliminates the overload operator and multiple inheritance features of C++, and eliminates the use of main files and preprocessors. Because Java has no structure, arrays and strings are objects, so Pointers are not needed. Java can automatically handle object references and indirect references, and realize automatic collection of useless units, so that users don’t have to worry about storage management problems, and can spend more time and energy on research and development.

2. Object oriented

Java is an object-oriented language. For programmers, this means paying attention to the data in and the methods used to manipulate it, rather than thinking strictly in terms of procedures. In an object-oriented system, a class is a collection of data and methods that manipulate that data. Data and methods together describe the state and behavior of an object. Each object encapsulates its state and behavior. Classes are organized in a hierarchy that allows subclasses to inherit behavior from superclasses. Within this class hierarchy there is a root class, which is a class with general behavior. Java programs are organized by classes.

Java also includes an extended collection of classes that make up packages that users can use in their own programs. For example, Java provides classes for generating graphical user interface widgets (the Java.AWT package), where AWT stands for Abstract Windowing Toolkit, Classes that handle input and output (java.io package) and classes that support networking capabilities (Java.net package).

3. Distribution

Java is designed to work on the web. It is a distributed language. Java supports both various levels of network connection and reliable stream network connection with the Socket class, so users can generate distributed clients and servers.

The network becomes a distributed vehicle for software applications. Java programs can be written once and run anywhere.

4. Compilation and interpretation

Java compilers generate byte-code instead of normal machine code. Java bytecode provides an architecture-neutral object file format, and code is designed to deliver programs efficiently to multiple platforms. Java programs can run on any system that implements a Java interpreter and run-time system.

In an interpretative environment, the standard “link” phase of program development largely disappears. If Java has a linking phase, it’s just a process of loading new classes into the environment, it’s an incremental, lightweight process. As a result, Java supports fast prototyping and easy experimentation, which will lead to fast program development. This is an elaborate development process in contrast to the traditional, time-consuming “compile, link and test” process.

5. Robustness

Java was originally developed as a language for writing software for consumer electronics, so it was designed to write highly reliable and robust software. Java eliminates some programming errors, making it relatively easy to write reliable software. Java is a strongly typed language that allows you to extend the ability to check for potential type mismatches at compile time. Java requires explicit method declarations, and it does not support C-style implicit declarations. These stringent requirements ensure that the compiler catches calling errors, which leads to a more reliable program. One of the most important enhancements to reliability is Java’s storage model. Java does not support Pointers, which eliminate the possibility of overwriting storage and corrupting data. Similarly, Java’s automatic “garbage collection” prevents storage leaks and other harmful errors related to dynamic storage allocation and unallocation. The Java interpreter also performs many runtime checks, such as verifying that all array and string accesses are within bounds. Exception handling is another feature of Java that makes programs more robust. An exception is a signal that some kind of error-like exception condition has occurred. Using try/catch/finally statements, programmers can find the error handling code, which simplifies the task of error handling and recovery.

6. Security

Java’s storage allocation model is one of its main defenses against malicious code. Java has no Pointers, so programmers can’t get hidden secrets and forge Pointers to storage. More importantly, Java compilers do not deal with storage arrangement decisions, so programmers cannot guess the actual storage arrangement of a class by looking at the declaration. Storage references in compiled Java code are determined at run time by the Java interpreter to the actual storage address.

The Java runtime system uses a bytecode validation process to ensure that code loaded onto the network does not violate any Java language restrictions. Part of this security mechanism includes how classes are loaded from the web. For example, loaded classes are placed in separate namespaces rather than local classes, preventing malicious applets from replacing standard Java classes with their own versions.

7. Portability Java makes language declarations independent of implementation aspects. For example, Java explicitly states the size and operation behavior of each primitive data type (which is described by Java syntax). The Java environment itself is portable to new hardware platforms and operating systems. Java compilers are also written in Java, while the Java runtime system is written in ANSIC.

8. High performance Java is a compiled and interpreted language, so it is not as fast as a fully compiled language. To support cases where performance is critical, however, Java designers create “just-in-time” compilers that translate Java bytecode into cpu-specific machine code at run time, thus achieving full compilation. The Java bytecode format was designed with these “just-in-time” compiler needs in mind, so the process of generating machine code is fairly simple, and it produces fairly good code.

Multithreaded Java is a multithreaded language that provides support for multithreaded execution (also known as lightweight procedures) and can handle different tasks, making it easy to design programs with threads. The Java lang package provides a Thread class that supports methods to start a clue, run a clue, stop a clue, and check the status of a clue. Java’s cue support also includes a set of synchronization primitives. These primitives are widely used synchronization schemes developed by C.A.R.Haore, based on supervisors and conditional variable models. Using the keyword synchronized, programmers can show that certain methods cannot be run concurrently in a class. These methods are under the control of a supervisor to ensure that variables remain in a consistent state.

Designed to adapt to changing environments, the Java language is a dynamic language. For example, classes in Java are loaded on demand, and some are even fetched over the network.

Principles of Java Cross-platform

Different platforms correspond to different VMS.

Java Compilation environment

Interpreter: Write a line of code to translate a line of code, more flexible, but consume time;

Just-in-time compiler: Compiles after code is finished, losing flexibility but running efficiently.

The Java virtual machine (JVM) shields the underlying platform from differences, implements one compilation, and runs anywhere. And a combination of two compilers)

The Java compiler

  • The name of the Java file must be the same as the name of the public class
  • A Java file can contain more than one class, but only one public class
  • Public static void main(String[] args) public static void main(String[] args) is the entry to all Java programs. If you want to execute the corresponding Java code, you must add the following method, and the format is fixed
  • The main parameter list can be written as String[] args,String [] args,String args[]
  • The names of the parameters in the main method do not matter, but are generally written as args
  • Java code needs to be written at the end of each line. The end of the
  • Blocks of Java code need to be bracketed with {} and matched before and after

Reference links: blog.csdn.net/buhuiguowan…

I am an architect less than brother

@ Terminal R&D Department

Focus on sharing Internet technology, workplace experience, technology, programming tips, I hope my share can help you ha