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

Compile to run on the computer, compile is to translate the code that people can understand into the form that machine can read

2 JavaThe advantages

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


3 Javaversion of

After SUN released Java1.2 , called Java called java2 , so now is called j2xx .

Features are divided into three versions:

J2SE Standard Edition ---- now most of the development is using it

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

J2ME Mini-board ---- only partially j2se functions for embedded systems. But not for Android Systems

Also,Android Development has its own version and does not belong to any of the above versions.

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 and install the IDE and jdk version j2se.

5Make up a little program to play

1) Run 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. Click Finish.

5) Open source code files, such as

Add code to the main function


It means the output string "Hello"

( Yes, not "Hello world!", compulsive disorder go to it )

6) Select Menu Run -- compile file

A new folder buildis generated at the root of the project, and the subfolders in the Classes folder contain the compiled files. You can see that Hello.java is 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) Click the Run button

The following results appear:

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

8) Explain this code

Package Hello pack name, source files must be placed in a package.

public class Hello declares a class, and the contents of the class are something in {} .

Public static void Main (string[] args) defines a method (or function), called main. Main method into a method, theJava program starts from the main function

System.out.println ("Hello"); Call a method that is in the Java SDK , meaning to output a string "Hello" in the Output Window.

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.