Java (1)--Basic overview

Source: Internet
Author: User


1.Java Running development environment

Sun released JDK1.0 (first edition) in early 1996. This version consists of two parts: the runtime Environment (JRE) and the development environment (JDK).

(1) The operating environment includes: Core API, Integration API, user interface API, publishing technology, Java Virtual Machine (JVM) 5 parts;

(2) The development environment includes: Compiling the Java program compiler (Javac command).


2.Java program operating mechanism and JVM:

(1) Instead of generating a platform-specific machine code, the Java language compiles a platform-independent bytecode (Xxx.class), which must be interpreted with the Java interpreter. For Java, the compilation and interpretation are indispensable, such as:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/79/B6/wKiom1aYo_aSGtOEAAB8mgUgpTA776.png "title=" em_ 2016115154621.png "alt=" Wkiom1ayo_asgtoeaab8mgugpta776.png "/>

(2) Java Virtual machine, the JVM (Java Vsan), is responsible for interpreting the execution bytecode. Java bytecode is not intended for any platform, only for the JVM. The JVM is different on different platforms, but they all provide the same interface;


Compilation and operation of 3.Java programs

(1) Using Notepad, compile the command: javac-d. Helloworld.java (-D indicates the directory in which the. class file is generated,.); Run command: Java Java class name (note: The runtime Java command is followed by the class name, not the. class file name, more than the source Java file name).

(2) Note that Java is case-sensitive.


4. About Java programs:

(1) The class is the smallest unit of a Java program. The simplest Java program is the program Class a{}, which only has an empty class, but the class can only be compiled through, but not run, because the Java program requires the main method to run the portal;

(2) The main method is almost fixed, that is, must be modified by public static void, the argument must be a string array type (string[] args), the General Java program has only one main method, Other methods are called directly or indirectly by the Main method;

5. Garbage collection mechanism

(1) The memory allocation and collection of Java programs are performed automatically by the JRE in the background, and the JRE recycles memory that is no longer used, known as garbage collection (garbage Collection-GC);

(2) The JRE will provide a background thread to detect and control, generally in the CPU idle or low memory of the automatic garbage collection, and program developers can not accurately control the time and sequence of garbage collection;

(3) The heap memory holds the instance object of all classes, if it is no longer referenced by the program, there is a garbage collection mechanism automatically released;

(4) In addition to releasing useless objects, the JVM can also be aware of memory fragmentation (fragmentation is the free memory area allocated to object memory), and the JVM allocates the compiled memory to new objects;

(5) A few notes on GC:

A.GC can only reclaim memory resources, for other physical resources: database connection, disk I/O resources are powerless;

B. To make the useless object recyclable as soon as possible, assign the object null;

C.runtime.getruntime (). GC (); and System.GC () are only recommended for recycling garbage;

This article is from "MySpace" blog, please make sure to keep this source http://wangzhaoli.blog.51cto.com/7607113/1736139

Java (1)--Basic overview

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.