JAVA (1), JAVA (

Source: Internet
Author: User

JAVA (1), JAVA (

I have been busy with other things for a few days. Now I start to learn JAVA. I will take the book "JAVA from getting started to proficient" as a teaching material and record the learning process of JAVA from this article.

Chapter 1

Objective: To build a JAVA environment and write out the first helloworld.

1. Download and install JDK

JDK1.8 is not very easy to use, and some colleagues can't use it after downloading it, so my JDK1.7

Address: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

I am using windows xp, so the followingJdk-7u65-windows-i586-demos.zip

Next, install it.

(1) double-click the. exe file to start JDK installation. JDK installation is very simple.

In the pop-up custom installation window, select the JAVA component to be installed and the JDK File Installation path. By default, click Next to complete the installation.

(2) Configure JDK

Right-click my computer on the desktop, and select Properties> advanced> environment variables from the pop-up menu. In the displayed window, set environment variables.

Click new in the system variable option, enter "PATH" in the variable name text box, and enter "C: \ Program Files \ Java \ jdk1.7.0 _ 02 \ bin;" in the variable value text box ;", be sure to end with a semicolon

Create a new system variable, enter "CLASSPATH" in the variable name text box, and enter "C: \ Program Files \ Java \ jdk1.7.0 _ 02 \ lib \ tools" in the variable value text box. jar; "must end with a semicolon

Click OK to save the changes.

Test whether the configuration is correct. Select Start> Run Command and enter javac in the displayed Run Command window. If javac usage instructions are displayed, the JDK configuration is successful. Otherwise, the configuration is incorrect. Reconfigure.

2. Use the Integrated Development Tool Eclipse

(1) download and install

Download the latest version 3.4from the official Eclipse website http://www.eclipse.org /.

Eclipse can be directly decompressed. Eclipse is in English. If you want to use Chinese, you can download the Chinese package. I use English directly.

The decompressed directory is as follows:

(2) Start Eclipse

Double-click eclipse.exe. Configure the Save path.

(3) Use Eclipse to develop JAVA, the first JAVA program --- HelloWorld

In the menu bar, click File --- New --- project. In the displayed project options, select a Java project and click Next to enter the new Java project. Enter the project name and click Finish.

In this case, the project is displayed in the project structure area of the Eclipse development window. Right-click the project name and choose create --- class command. In the displayed window, the default package name is not added, next, enter the Java class name HelloWorld, and then select the first method to be created in the method stubs, that is, the main method, because it makes a class entry. After entering these information, click Finish.

In the editing area, the code of the basic HelloWorld framework is displayed. Enter the functional statement. For example.

    

(4) Compile and run

Eclipse compilation and running are integrated and do not need to be executed separately. In the menu bar, click Run> run mode> Java run program, and click OK in the pop-up save and start window.

Now, the first HelloWorld is running, and the HelloWorld information is output.

 


What software is Java?

A Java virtual machine is a runtime environment. You can add it to a Web browser or any Operating System (for example, IBM Operating System/400 (OS/400. Commands generated by running the Java compiler on the Java Virtual Machine. It consists of a bytecode interpreter and a runtime. Regardless of the platform on which Java files were originally developed, they are allowed to run on any platform.

The classloader and Security Manager are part of the Java runtime and they isolate code from another platform. They can also restrict the system resources that can be accessed by each mounted class.

Note: Java applications are not restricted; only applets are restricted. Applications can freely access system resources and use local methods. Most AS/400 Developer Kit for Java programs are applications.

You can use the "Create Java program" (CRTJVAPGM) command to ensure that the Code meets the security requirements implemented to verify bytecode during Java runtime. This includes mandatory type restrictions, checking for data conversion, ensuring that parameter stack overflow or overflow does not occur, and checking for access violations. However, you do not need to explicitly verify the bytecode. If the CRTJVAPGM command is not used in advance, the system checks when a class is used for the first time. After the bytecode is verified, the interpreter decodes the bytecode and runs the machine commands required to perform the desired operation.

Note: You can use the Java interpreter only when OPTIMIZE (* INTERPRET) or INTERPRET (* YES) is specified.

In addition to loading and running bytecode, the Java Virtual Machine also includes a useless unit collector for memory management. Useless Unit collection and bytecode loading and interpretation are executed simultaneously.

The Java interpreter is part of a Java Virtual Machine and explains Java class files for a specific hardware platform. The Java interpreter runs each bytecode and runs a series of machine commands on the bytecode.

The javac tool reads classes and interface definitions written in the Java programming language and compiles them into bytecode class files.

Can a java file define many classes?

A. java file can contain many classes. However, pay attention to the following points:
1. Only one public permission class can be assigned (or none can be assigned, but only one class can be assigned at most)
2. The file name of this. java file must be the class name of the public class (in general, the main method is placed here as the entry of the program .)
3. If there is no public class in this file, the file name is a class name.
4. When you use Javac to compile this. java file, it will generate a. class file for each class.

The figure you sent can run, because there is a public class containing the main method, and this main () method is the entry of the program.
The execution sequence of this program is as follows: after entering the main method, a ChildClass object is first created. The subclass object enters the f () method and calls f () in the FatherClass, complete the method body after self-execution

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.