Java 0 Basics Run the first program

Source: Internet
Author: User
Tags netbeans

Java 0 Basics Run the first program

An overview of 1 JavaCode compilation

Post-compilation talent is performed on the computer. Compiling is the conversion of code that people can read into a form that the machine can understand.

2 Javathe Strengths

Compile once. Executed everywhere. Because Java code is executed in a virtual machine, the virtual machine eliminates differences between different operating systems. Java Virtual Machine--- abbreviation JVM


3 Javathe version number

SUN Company announced Java1.2 later, called the Java called java2 , so now is called j2xx .

The feature is divided into three version numbers:

J2SE Standard Edition ---- Most of today's development uses it

Java EE Enterprise Edition ---- features the most, is j2se 's extended version

The J2ME mini-board ---- has only part of the J2SE function for embedded systems.

But not for Android Systems

And also. Android Development has a version number of its own. Does not belong to one of the above no matter what version number.

4 JavaDevelopment Environment Construction

Install the JDK and development tools address :

Http://www.oracle.com/technetwork/java/javase/downloads/index.html

Download the Netbeans with JDK directly. Will install the IDE and the JDK version j2se .

5Make up a little program to play

1) Executing netbeans

2) Menu -- new

3) The following dialog box appears


SelectJava applicationand click Next.

4) The following content appears


The project name changes to Helloand the rest changes. Point is complete.

5) Open source code files, such as

Add code to the main function


It means the output string "Hello"

( yes.) Not "Hello world!". Obsessive Compulsive disorder go to it )

6) Select Menu Execution -- compile file

A new directory buildis generated at the root of the project, and subdirectories in the classes directory include the compiled files. Can see that Hello.java was compiled into a hello.class.

Can't find the path where the project is located ?

Put the mouse on the Tab Control (arrow), a prompt box appears, and the red line indicates the root directory of your project.

7) Point Execution button

Occurrences such as the following result:

Can't you see that ? you still have to stop learning this line ...

8) Explain this code

Package Hello pack name. The source code file must be placed in a package.

public class Hello declares a class. The content of the class is something in {} .

Public static void Main (string[] args) defines a method (or function). The method is called main. The main method is in a method, andtheJava program starts with the main function

System.out.println ("Hello"); Call a method, which is taken in the Java SDK , meaning to output a string "Hello" in the output form.

Java 0 Basics Run the first program

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.