Create and run a simple Java program

Source: Internet
Author: User

Developing a Java application typically consists of three steps :

1. Create a source file with the file name extension *.java

1). Using the editor (such as Notepad, the notepad++ is used), enter the following 6 lines of text:

1 // A simple application example: print a line of text 2 class Hello {3      Public Static void Main (String args[]) {4         System.out.println ("Hello java,this is my first Java application!" ); 5     }6 }

The input is complete, as shown in

  

2). Name the file name Hello.java, and save it,

2. Using the Java Editor Javac.exe compile the source file to generate a byte-code file with the file extension *.class

1). win+r, enter CMD in the text box, and enter into the DOS window.

2). Use the CD command to transfer the path to the path where the source file "Hello.java" is located (CD usage can refer to the CD command of the Doc window), enter the "Javac Hello.java" command.

At the same time, we can find the source file "Hello.java" in the folder of a more than one bytecode file (editor Javac.exe compiled results), this is the right.

3. Java.exe running bytecode using the Java interpreter

Under current path, enter "Java Hello" command, carriage return. The operation results are as follows

The road to Java is successful.

Summarize

Use Notepad to write code that has a positive effect on the typing habit, while running the code with a DOS window to better understand the entire process of running Java.

Good programmers must have good habits!

The Essays! 2017-05-11 22:37:23

To create and run a simple Java 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.