Compiling Java code under 02MAC

Source: Internet
Author: User

Configure JDK 1.7 on Mac OS.

Download the Mac version of JDK1.7

From the following, download the Mac version of the JDk1.7 installation file jdk-7u79-macosx-x64.dmg.

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Two-Mount JDK

1) Click jdk-7u79-macosx-x64.dmg and follow the prompts to install the JDK.

2) After the installation is complete, in the console input command view version, there will be a response output, indicating the successful installation of JDK7.

[Email protected] ~$ java-"1.7.0_79"1.7. 0_79-   24.79-b02, Mixed mode)

Three first Java programs

1) Create a new Java file Helloworld.java

Touch Helloworld.java

2) Edit and save the following code.

 Public class HelloWorld {    publicstaticvoid  main (string[] args) {        System. out. println ("Hello world! " );    }}

Attention

    • The Java program code suffix is. java.
    • Java file names and class names are consistent, and the Java language is strictly case-sensitive.

3) Convert the Helloworld.java to Helloworld.class using the Javac command.

Javac Helloworld.java

When the command executes successfully, it will find more helloworld.class files.

4) Running the program

After the code is converted to a. class file, you can run it under the JVM virtual machine and enter the following command.

Java HelloWorld

Note that this is actually running Helloworld.class, but the command does not use the suffix name.

Summarize:

The. Java suffix is the source code, one or more source code to be produced by the Java compiler. class suffix bytecode. Bytecode is not related to the platform, and the C language to compile production platforms associated with the machine code is not the same. The machine code can be executed directly on the platform, and the bytecode executes when the interpreter is executed.

The. class file is read and interpreted as the process of platform-related machine code execution. and the compiler language (such as C) The biggest difference is that the Java program must be interpreted by the interpreter to the platform-related machine code to execute, it can be seen in the process of dynamic interpretation, and the compiled language (such as C) is compiled before the implementation of the platform-related machine code. This is the important reason that the Java language can be "compiled once, run everywhere".

Compiling Java code under 02MAC

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.