Roaming Java--helloworld Chapter

Source: Internet
Author: User

Newly registered blog, approval is very fast, below to write down the first blog to stay in the blog park.

This time to prepare some information about the introduction of Java, for what, recently the family noisy to learn Java, I want to give her class, "hehe."

You walk through the great gods, there are good advice welcome welcome, good, words do not say, Roaming Java Basic article--helloworld.

Java is an object-facing development language, I believe you know, similar languages are actually many, such as the. NET platform of C # and so on. As for the concept of object-oriented, I do not swim here, want to delve into the "object-oriented" beginners, go to the homepage to see "Object-oriented understanding----the beginning of new knowledge" This article, although not based on Java, but the same thinking.

This time does not talk about the past also does not talk about the future, only writes the HelloWorld to be good.

Before we start writing our first Java applet, let's do the preparatory work:

First, the development environment to build

Write the program, certainly is on the basis of a certain person, some basic is not much to say, the computer has it! The operating system must be installed! Oh, it's nonsense.

Java in addition to object-oriented, or a feature is cross-platform. Why is it cross-platform, just as with Java programs running on the Java Virtual Machine (JVM), of course, the JVM is not cross-platform, different operating systems have different JVMs, so that the same Java program can run on different operating system JVM, so it is cross-platform.

The JVM is the most central part of the entire Java implementation cross-platform, and all Java programs are first compiled into a. class file that can be executed on a virtual machine, that is, the class does not directly correspond to the machine's operating system, but is indirectly interacting with the operating system through the virtual machine. The program is interpreted by the virtual machine to the local system for execution.
The JVM is the foundation of the Java platform, which, like the actual machine, has its own set of instructions and operates in different memory areas at runtime. By abstracting the operating system and CPU structure, the JVM provides a platform-independent code execution method that is independent of the special implementation method, host hardware, and host operating system. But in some small ways, the implementation of the JVM is not the same, such as garbage collection algorithm, thread scheduling algorithm (perhaps different OS have different implementations).
The main task of the JVM is to explain its own set of instructions (that is, bytecode) to the CPU's instruction set or OS system calls to protect the user from malicious program harassment. The JVM does not care about the upper Java source files, it only focuses on the class file generated by the source file. The composition of the class file includes the JVM instruction set, the symbol table, and some subsidy information.

In addition to the JVM, there are two other very important things: the JRE and the JDK.

  JRE-Java Runtime Environment
The JRE refers to the Java Runtime environment. The JVM cannot be executed as a class, because the JVM needs to invoke the class library lib that is needed to interpret the classes. There is a JVM inside it. The JRE is related to the specific CPU structure and operating system, and we see different versions of the JRE when we download it. There are also APIs (such as AWT, swing, and so on) that make up the JRE together with the JVM. The JRE is essential for running Java programs.

  JDK--Java Development Kit
The JDK is the Java SDK, which means we have to install the JDK to develop Java programs.

Next, we'll first download the JDK and install it. JDK is now 1.8, the official website is easy to find 1.7, 1.8 version, but this series of introduction is based on jdk1.6 ah, haha, is not outdated.

Download the JDK and install it, the process is nothing to say. Installation is complete, the first to set environment variables, open the environment variable Configuration Interface operation is (Win7 system): Right-click "Computer"-"Properties"-"Advanced system Settings"-"Advanced"-"environment variables, as shown:

Then locate the path in the System variables list below and double-click into edit state,

It's been a long day, what are we going to configure? Open the JDK installation directory: E:\Program files\java\jdk1.6.0_23 (my). Here to say, the JDK is installed by default in the name of the Java file, there are jdk,jre two directories, which corresponds to the above introducer Jdk,jre, so we installed the JDK can develop and run Java programs. Then before the problem, we went into the JDK directory,

Bin: The main thing is the compiler (Javac.exe)
Include:java header files for interaction with the JVM
LIB: Class Library
Jre:java Operating Environment
Demo and sample: some nice little programs to write

Careful child shoes found out there is a JRE, there is a JRE, in fact, the two are the same, but the division of labor slightly different, when the user is only used to run external Java programs, only use the outside of the JRE, if you are a developer, running programs in the development environment, generally prefer to use the JDK directory of the JRE.

Now we can finally find out what we are going to configure in path, that is, the JDK bin directory, take my machine as an example: E:\Program files\java\jdk1.6.0_23\bin

After determining the configuration, the success or not, we have to verify, enter CMD, enter the Java return, output such as:

Here, congratulations, you have succeeded.

Second, the first Java program--helloworld

Beginners recommend using a text editor to write code, and then use the IDE when you are proficient.

Start writing, set up a new folder under the F-disk Java, in the directory to build another folder one, into the single file, new TXT file, and then the same name as HelloWorld, modify the suffix. java. Open the file with a text editor and write the following code:

public class HelloWorld{

public static void Main (String args[]) {
System.out.println ("helloworld!");
}
}

After editing, remember to save, and then cmd to execute the command "f:--" CD F:\java\one"into the one directory.

The source code has been written, we need to compile the. Java source code, generate a. class file,

Execute compile command:javac Helloworld.java

The Helloworld.class file is generated in the one directory. Then run the. class file to start the program.

Run command:java HelloWorld

Specific process effects such as:

To this, the HelloWorld small program runs successfully, is not very simple, move hands will be more simple.

Well, first here today, things are not much, but also very tiring, there are some things to say, the time problem, next time to fill, feel useful please continue to pay attention to, encourage

Roaming Java--helloworld Chapter

Related Article

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.