Chapter 1 of Java ---- Java Overview + Environment setup, java ---- java

Source: Internet
Author: User

Chapter 1 of Java ---- Java Overview + Environment setup, java ---- java
Preface:

I have read the basics of Java several times, but I have forgotten it after a while. So this time I decided to spend some time organizing a series of blogs for future reference. This series is based on the Java programming ideology + the core Java technology. These two books are also two I strongly recommend to you, because each reading has different gains, you will be benefited from the two horizontal views!

Section 1: Java Introduction

  Java is an object-oriented programming language launched by Sun IN May 1995. It is an excellent Implementation of the object-oriented theory and pays more attention to the process of the object itself rather than the event.

Java consists of four parts: Java programming language + Java class Format File + Java Virtual Machine + Java application interface. We define different class files through IDE and call the class method (Java API) to access the resource system and compile the source file. class file, run the file through the Java Virtual Machine.

Java White Paper:

  • Simplicity: The syntax is simple and easy to understand. Excluding the header file pointers that are hard to understand in C ++, the class library is small. However, with the increase of class libraries and the increase of thread support, the object-oriented architecture is as follows: focus more on the object itself, rather than the implementation process.
  • Network skills: Java has simple and easy-to-use network capabilities. It is used to process TCP/IP protocols such as http or ftp and allows users to open or access objects on the network through URLs.
  • Robustness: Java's strong type mechanism, exception handling, and automatic garbage collection are important guarantees for Java program robustness. Java uses the pointer model to eliminate the possibility of overwriting memory and damaging data. Java does not need to use pointers to construct string arrays and other mechanisms. However, if necessary, Java also has the pointer capability, such as the linked list.
  • Security: Java has no pointer, so programmers cannot obtain hidden insider and counterfeit pointers to memory. More importantly, Java compilation programs do not handle storage arrangement decisions, so programmers cannot guess the actual storage arrangement of classes by viewing statements. The storage reference in compiled Java code is determined by the Java interpreter at runtime.
  • Portability: Java makes language declarations independent of implementation. For example, Java explicitly describes the size of each basic data type and its operation behavior (these data types are described by Java syntax ). The Java environment itself is portable to new hardware platforms and operating systems. Java compilation programs are also written in Java, while the Java runtime system is written in ANSIC language.
  • Description: The Java program is compiled as a byte code format on the Java platform, and can then run in any system that implements the Java platform. During runtime, the Java interpreter on the Java platform interprets and executes these bytecode, And the classes required during execution are loaded into the runtime environment during the connection stage.
  • High Performance: Java programs can run on any system that implements the Java interpreter and runtime system.
  • Multithreading: multithreading can bring better interaction response and user behavior.
  • Dynamic: the Java language is designed to adapt to the changing environment. It is a dynamic language. For example, classes in Java are loaded as needed, and some are obtained through the network.
Section 2: Java Development History Section 3: Build a Java Development Environment
  • JDK (Java Development Kit): software used by programmers who write Java programs
  • JRE: software used to run Java programs
  • IDE: integrated development environment such as eclipse and idea

JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html. Note: The default installation path is under Program Files. It is best to replace the path or spaces to avoid unnecessary troubles.

Directory structure:

    • Bin: compiler and Tool
    • Db: relational database files developed by Java
    • Include: files used to compile local methods
    • Javafx-src: JavaFX script is a declarative and static programming language.
    • Jre: Java Runtime Environment File
    • Lib: Class Library File
    • Src: Class Library source file

Environment Variable Configuration:

JAVA_HOME: D: \ Java \ jdk1.8.0 _ 31 points to the jdk installation directory. Eclipse, NetBeans, Tomcat, and other software find and use the installed jdk by searching the JAVA_HOME variable.

PATH: % JAVA_HOME % \ bin; specifies the command search PATH. Execute the command below the command line, for example, when javac compiles a java program, it will go to the PATH specified by the PATH variable to check whether the corresponding command program can be found. We need to add the bin directory under the jdk installation directory to the existing PATH variable. The bin directory contains frequently used executable files such as javac/java/javadoc waiting, after setting the PATH variable, You can execute tools such as javac and java in any directory.

CLASSPATH :.; % JAVA_HOME %/lib/dt. jar; % JAVA_HOME %/lib/tools. jar is used to specify the Class search path. To use the classes that have already been compiled, the premise is that you can find them. JVM searches for classes through CLASSPATH. We need to set dt. jar and tools. jar in the lib subdirectory under the jdk installation directory to CLASSPATH. Of course, the current directory "." must also be added to this variable.

Environment Variable Verification:

CMD verification: Enter Java-version, and then press enter to the console to output the jdk version number, indicating that the installation is successful.

Create a new HelloWorld. java file, enter the corresponding directory, enter javac HelloWorld. java, press enter, enter java HelloWorld, and then press enter to output Hello World on the console, indicating that the environment variable is successfully configured.

Note: The javac program is a Java compiler that compiles HelloWorld. Java into a HelloWorld. class file and sends it to the Java Virtual Machine. The virtual machine executes the bytecode of the compiler in the class file.

Note: during compilation, you must provide the file to be compiled with the extension name HelloWorld. java. during runtime, you only need to specify the class name, without the suffix HelloWorld.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.