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
*`-H:Dump= -H:MethodFilter=ClassName.MethodName`: dump the compiler graphs of the `native-image` builder.
134
135
*`-XX:Dump= -XX:MethodFilter=ClassName.MethodName`: dump the compile graphs at runtime.
135
136
137
+
## System Properties
138
+
139
+
You can define system properties at image build time using the `-D<system.property>=<value>` option syntax.
140
+
It sets a system property for the `native-image` tool, but the property will not be included in the generated executable.
141
+
However, JDK system properties are included in generated executables and are visible at runtime.
142
+
143
+
For example:
144
+
*`-D<system.property>=<value>` will only be visible at build time. If this system property is accessed in the native executable, it will return `null`.
145
+
*`-Djava.version=24` will be visible at both build time and in the native executable because the value is copied into the binary by default.
146
+
147
+
The following system properties are automatically copied into the generated executable:
If you build a native executable using `native-image -Dfoo=bar App`, the system property `foo` will be available at *executable build time*.
20
+
If you build a native executable using `native-image -Dfoo=bar App`, the system property `foo` will **only**be available at build time.
21
21
This means it is available to the [code in your application that is run at build time](http://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/ImageInfo.html#inImageBuildtimeCode--) (usually static field initializations and static initializers).
22
-
Thus, if you run the resulting executable, it will not contain `foo` in the printed list of properties.
22
+
But if you run the resulting executable, it will not contain `foo` in the printed list of properties.
23
23
24
-
If, on the other hand, you run the executable with `app -Dfoo=bar`, it will display `foo` in the list of properties because you specified property at *executable run time*.
25
-
26
-
In other words:
27
-
* Pass `-D<key>=<value>` as an option to `native-image` to control the properties seen at build time.
28
-
* Pass `-D<key>=<value>` as an option to a native executable to control the properties seen at run time.
24
+
If, on the other hand, you run the executable with `app -Dfoo=bar`, it will display `foo` in the list of properties because you specified this property.
29
25
30
26
## Read System Properties at Build Time
31
27
32
-
You can read system properties at build time and incorporate them into the resulting executable file, as shown in the following example.
28
+
You can read system properties at build time and incorporate them into the native executable, as shown in the following example.
33
29
34
30
### Prerequisite
35
31
Make sure you have installed a GraalVM JDK.
@@ -116,5 +112,5 @@ For other installation options, visit the [Downloads section](https://www.graalv
116
112
117
113
### Related Documentation
118
114
119
-
* [Class Initialization in Native Image](../ClassInitialization.md)
115
+
* [Command-line Options: System Properties](../BuildOptions.md#system-properties)
120
116
* [Specify Class Initialization Explicitly](specify-class-initialization.md)
0 commit comments