You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -56,8 +56,8 @@ cd graalvm-demos
56
56
<td align="left" width="70%">Demonstrates how you can influence the classes initialization at the image build time<br><strong>Technologies: </strong>Native Image, Maven<br><strong>Reference: </strong><a href="https://medium.com/graalvm/understanding-class-initialization-in-graalvm-native-image-generation-d765b7e4d6ed">Understanding Class Initialization in GraalVM Native Image Generation</a></td>
<td align="left" width="70%">A web server application, using the Netty framework, to demonstrate the use of isolates with Native Image<br><strong>Technologies: </strong>Native Image, Maven, Netty<br><strong>Reference: </strong><a href="https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-ed6f14ff7692">Instant Netty Startup using GraalVM Native Image Generation</a></td>
<td align="left" width="70%">Demonstrates how to debug a Java application, built into a native executable in VS Code<br><strong>Technologies: </strong>Native Image, Maven, GraalVM Tools for Java<br><strong>Reference: </strong><a href="https://medium.com/graalvm/native-image-debugging-in-vs-code-2d5dda1989c1">Native Image Debugging in VS Code</a></td>
For compilation, the `native-image` depends on the local toolchain.
28
-
Please make sure that `glibc-devel`, `zlib-devel` (header files for the C library and zlib), and `gcc` are available on your system. Some Linux distributions may additionally require `libstdc++-static`.
29
+
Make sure that `glibc-devel`, `zlib-devel` (header files for the C library and zlib), and `gcc` are available on your system. Some Linux distributions may additionally require `libstdc++-static`.
29
30
See [Prerequisites for Native Image](https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites).
30
31
31
-
## Build the Project
32
+
## Build the Application
32
33
33
34
The example is built with Maven:
34
35
```bash
35
36
mvn package
36
37
```
37
38
38
-
This creates a JAR file with all dependencies embedded: `target/netty-plot-0.1-jar-with-dependencies.jar`.
39
+
This creates a JAR file with all dependencies embeddedin the _target/_ directory.
39
40
40
41
## Generate a Native Executable
41
42
42
43
If the application is expected to use some dynamic features at run time (e.g., Reflection, Java Native Interface, class path resources), they have to be provided to the `native-image` tool in the form of configuration files.
43
44
To avoid writing the configuration file yourself, apply the [tracing agent](https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/) when running on the Java HotSpot VM.
44
45
It will observe the application behavior and create configuration files (_jni-config.json_, _reflect-config.json_, _proxy-config.json_ and _resource-config.json_) in the _META-INF/native-image_ directory on the class path.
45
-
The _reflect-config.json_ file specifies classes which must be available via Java reflection at runtime.
46
+
The _reflect-config.json_ file specifies classes which must be available via Java reflection at run time.
46
47
47
-
1. Run the application on GraalVM JDK applying the tracing agent:
48
+
1. Run the application on the GraalVM JDK applying the tracing agent:
The server is started. Open _http://127.0.0.1:8080/?useIsolate=false_in the browser to see the output.
52
+
The server is started. Open [http://127.0.0.1:8080/?useIsolate=false](http://127.0.0.1:8080/?useIsolate=false)in the browser to see the output.
52
53
53
54
2. Terminate the application, `CTRL+C`.
54
55
@@ -58,33 +59,34 @@ The _reflect-config.json_ file specifies classes which must be available via Jav
58
59
```
59
60
The result is an executable file that is around 22 MByte in size:
60
61
```bash
61
-
du -h netty-plot
62
-
22M netty-plot
62
+
du -h target/netty-plot
63
63
```
64
64
65
65
4. You can now run the executable:
66
66
```bash
67
67
./netty-plot
68
68
```
69
-
Open your web browser and navigate to http://127.0.0.1:8080/
69
+
Open your web browser and navigate to [http://127.0.0.1:8080/](http://127.0.0.1:8080/)
70
70
71
-
5. Finally, you can open your browser and request rendering of a function, for example, by browsing to `http://127.0.0.1:8080/?function=abs((x-31.4)sin(x-pi/2))&xmin=0&xmax=31.4`.
71
+
5. Finally, you can open your browser and request rendering of a function, for example, by browsing to [http://127.0.0.1:8080/?function=abs((x-31.4)sin(x-pi/2))&xmin=0&xmax=31.4](http://127.0.0.1:8080/?function=abs((x-31.4)sin(x-pi/2))&xmin=0&xmax=31.4).
72
72
73
73
### Background Information
74
74
75
75
Instead of specifying any additional parameters on the command line, they may provided in a properties file in the input JAR file.
76
-
The `native-image` builder automatically looks for files named `native-image.properties` and for any other configuration file under `META-INF/native-image` including subdirectories, and processes their contents.
76
+
The `native-image` builder automatically looks for files named _native-image.properties_ and for any other configuration file under _META-INF/native-image_ including subdirectories, and processes their contents.
77
77
The tracing agent writes the _reflect-config.json_ file specifying classes which must be available via Java reflection at run time.
78
78
79
-
With Maven projects, the path convention is `META-INF/native-image/${groupId}/${artifactId}/native-image.properties`.
80
-
In this example, the `META-INF/native-image/com.oracle.substratevm/netty-plot/native-image.properties` file contains the following:
79
+
With Maven projects, the path convention is _META-INF/native-image/${groupId}/${artifactId}/native-image.properties_.
80
+
In this example, the _META-INF/native-image/com.oracle.substratevm/netty-plot/native-image.properties_ file contains the following:
81
81
```bash
82
82
ImageName = netty-plot
83
83
Args = --link-at-build-time
84
84
```
85
85
The `ImageName` property specifies the name of the resulting executable, while`Args` are treated like additional command-line arguments.
86
86
87
-
### A note about the application
87
+
#### A note about the application
88
88
89
-
This example cannot run as a regular Java application (on the JVM) and it cannot be profiled.
89
+
This example cannot run as a regular Java application (on HotSpot) and it cannot be profiled.
90
90
It will fail because the program tries to create an [isolate which is a Native Image specific feature](https://medium.com/graalvm/isolates-and-compressed-references-more-flexible-and-efficient-memory-management-for-graalvm-a044cc50b67e).
91
+
92
+
Read more in the blog post [Instant Netty Startup using GraalVM Native Image Generation](https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-ed6f14ff7692).
Copy file name to clipboardExpand all lines: native-netty-plot/src/main/resources/META-INF/native-image/com.oracle.substratevm/netty-plot/native-image.properties
0 commit comments