Introduction to the

Install GraalVM in Ubuntu and compile a local executable. Win10 下 install please refer to: this article

reference

www.graalvm.org/docs/gettin… www.graalvm.org/reference-m…

The installation

1. Download the tar package and decompress it

wget https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.3.0/graalvm-ce-java11-linux-amd64-20.3.0.tar.gz tar - XZF graalvm - ce - java11 - Linux - amd64-20.3.0. Tar. GzCopy the code

2. Set environment variables

Bashrc export PATH=/root/ Graalvm-ce-java11-20.3.0 /bin:$PATH export JAVA_HOME=/root/ Graalvm-ce-Java11-20.3.0 source  ~/.bashrc java -versionCopy the code



3. Install the native – image

gu install native-image  
gu list
Copy the code



4. Install the local tool chain

sudo apt-get install build-essential libz-dev zlib1g-dev   
Copy the code

5. Write Java code, compile, and generate local executable files

vi Test.java
Copy the code
public class Test {
    public static void main(String[] args) {
        System.out.println("hello graalvm"); }}Copy the code
javac Test.java  
native-image Test  
Copy the code



6. Execute the local executable file



You can see that the resulting executable is about 9M in size

// Execute the local executable./test Hello GraalvmCopy the code