Java starts the first program with Zero Foundation, and java starts the first program.

Source: Internet
Author: User
Tags netbeans

Java starts the first program with Zero Foundation, and java starts the first program.

Java starts the first program

I. Overview 1 java code compilation

After compilation, it can be run in the computer. Compiling is to convert the code that people can understand into a form that machines can understand.

2 java advantages

One compilation, run everywhere. Because java code runs in a virtual machine, the virtual machine eliminates the differences between different operating systems. Java Virtual Machine --- JVM for short


3. java version

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

 

Functions are divided into three versions:

J2SE standard version ---- most development uses it now

J2EE Enterprise Edition-the most functional version is the extended version of J2SE

J2SE microboard-only some J2SE functions are available for embedded systems. But not for Android

In addition, android development has its own version and does not belong to any of the above versions.

4. Build a java Development Environment

Install JDK and development tools:

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

Directly download "Netbeans with JDK" and install IDE and JDK J2SE together.

5. Compile a mini program for fun

1) Run netbeans

2) menu -- New

3) The following dialog box appears.


Select "Java application" and click "Next ".

4) the following content appears:


The project name is changed to Hello, and the rest are changed. Click Finish.

5) Open the source code file, such

 

Add code to the main function


 

The output string "Hello"

(Yes, not "Hello World !", Obsessive-compulsive disorder)

6) Select the menu to run-compile the file

A new build folder is generated under the root directory of the project. The subfolders in the classes folder contain the compiled files. We can see that hello. java has been compiled into hello. class.

Cannot find the project path? Place the mouse over the Tab control (pointed by the arrow) and a prompt box appears. The red lines indicate the root directory of your project.

 

 

7) Click "run ".

 

 

The following result is displayed:

 

 

Can't you see it? You should stop learning this line...

 

8) Explain the code.

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

Public class Hello declares a class whose content is something in.

Public static void main (String [] args) defines a method (or function) called main. The main method has a method. The java program starts to execute the main function.

System. out. println ("Hello"); call a method, which is included in the Java SDK, meaning that a string "Hello" is output in the output window ".

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.