[Java] Thinking in Java exercise 2.2

Source: Internet
Author: User

Topic

Create a "Hello, World" program, compile it with Javac, and then run it in Java.

Program

1  Public class ex2_2 {2      Public Static void Main (string[] args) {3         System.out.println ("Hello, World"); 4     }5 }

Compiling and running

Win+r Run cmd

D: Change to D drive, CD (space) file path, arrival program Ex2_2.java Directory

Format of the Javac command: javac-d destdir srcfile (Destdir:java bytecode storage path Srcfile:.java source file location)-D: Used to specify the path of the class file after compilation, if omitted, it is stored in the default path, the current directory is available "." Instead, such as javac-d. Srcfile Enter HERE
1 javac-d. Ex2_2.java

Or

javac-d D:\eclipse-workspace\HW\src D:\eclipse-workspace\HW\src\Ex2_2.java

Generates a. class file. Run it again in Java.

Format of the Java command: Java srcfile

Enter HERE

1 Java ex2_2

Get!

[Java] Thinking in Java exercise 2.2

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.