Accustomed to the IDE and ready-made compile tools provide us convenient compilation, we rarely worry about the compilation process and principle of compiler tools, but the more advanced tools, hide the more details, this compilation we have a problem is difficult to locate, encounter complex projects (especially cross-platform project is difficult to use the IDE) do not know how to do when. So I’m going to write two articles on compilers and compilation tools. This article starts with the compilation tools.

Mainly engaged in Android development, this paper mainly introduces Android, iOS used programming language and compiler.

Java/Kotlin/Groovy

All three programming languages are based on the Java Virtual Machine. Because of the JVM, Java is both a compiled and interpreted language. Think of the JVM as an operating system, which is a compiled language; From the point of view of a physical operating system, it is also interpretive. The JVM is responsible for interpreting the compiled.class into binary bytes that the final CPU understands. It sacrifices efficiency for cross-platform.

Java compiler

Let’s start with a simple HelloWorld.

public class HelloWorld{
    public static void main(String[] args){
        System.out.println("Hello, World!");
    }
}
Copy the code

Call it HelloWorld.java. Remember that Java gave us the compilation tool Javac and the execution tool Java, respectively? We compile using Javac:

javac HelloWrold.java
Copy the code

Java statistics directory with helloWorld.java statistics directory with HelloWorld.class generated, we continue to execute the class file:

qingkouwei:~/javaLinux/w1$ java HelloWorld.class
Error: Could not find or load main class HelloWorld.class
Copy the code

We passed the name of the class in which the main function is located, not the class file. Java automatically finds the class file based on the class name. Let’s change to Java HelloWorld and see the output.

Compile with package name class

The above example is too simple, let’s add the package name to it:

package com.qingkouwei.demo;
public class HelloWorld{
    public static void main(String[] args){
        System.out.println("Hello, World!");
    }
}
Copy the code

Kotlin

Groovy

C/C++

dart

oc/swift

conclusion