Simple compilation of HelloJava. java files and precautions

Source: Internet
Author: User

Simple compilation of HelloJava. java files and precautions

Compile the HelloJava. java file:

  1. Public class HelloJava {
  2. /*
  3. 1. The source file ends with. java
  4. 2. The source file can contain classes declared by multiple classes.
  5. 3. The class can have the main method (that is, the main () method). The format is fixed: public static void main (String [] args ){}
  6. 4. The main () method is the program entry, and the method is the execution part of the program.
  7. 5. Only one public class can be declared in a source file, and the class name must be consistent with the source file name.
  8. 6. Each statement ends ";"
  9. 7. Execute the program: ① compile: After javac.exe is compiled, many. class bytecode files are generated. ② Run: java.exe
  10. 8. Multi-line comments cannot be nested
  11. */
  12. Public static void main (String [] args ){
  13. System. out. println ("Hello World! "+ '\ N' +" Hello kvoice! ");

  14. }
  15. }

  16. Class Person {
  17. // Defines another class
  18. }

  19. Class Hello {
  20. // Defines another class
  21. }

The development procedure is as follows:
① Write the Java code to the. java file;
② Use the javac command to compile the. java source file into a. class bytecode file;
③ Use java commands to generate the generated bytecode file. class;
Eg:

Run the following command:
Javac HelloJava. java
Java HelloJava

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.