前置条件-完成环境配置: 使用Graalvm编译native-image(一)环境配置
最简实践
- 编写HelloWorld.java:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } - 编译打包
生成文件如下:E:\Main>javac HelloWorld.java E:\Main>java HelloWorld Hello World E:\Main>native-image HelloWorld [helloworld:3512] classlist: 6,242.93 ms, 0.96 GB [helloworld:3512] (cap): 6,184.78 ms, 0.96 GB [helloworld:3512] setup: 10,838.76 ms, 0.96 GB [helloworld:3512] (clinit): 532.53 ms, 1.73 GB [helloworld:3512] (typeflow): 21,617.22 ms, 1.73 GB [helloworld:3512] (objects): 13,348.47 ms, 1.73 GB [helloworld:3512] (features): 1,921.54 ms, 1.73 GB [helloworld:3512] analysis: 38,192.17 ms, 1.73 GB [helloworld:3512] universe: 3,686.24 ms, 1.73 GB [helloworld:3512] (parse): 5,677.75 ms, 1.73 GB [helloworld:3512] (inline): 14,982.90 ms, 1.77 GB [helloworld:3512] (compile): 39,547.64 ms, 1.81 GB [helloworld:3512] compile: 62,799.48 ms, 1.81 GB [helloworld:3512] image: 1,659.97 ms, 1.81 GB [helloworld:3512] write: 1,476.88 ms, 1.81 GB [helloworld:3512] [total]: 125,787.95 ms, 1.81 GB # Printing build artifacts to: E:\Main\helloworld.build_artifacts.txt