News and views from members of the Java team at Oracle
The OpenJDK Quality Group promotes the testing of FOSS projects with OpenJDK early-access builds as a way to improve the overall quality of the release. This heads-up is part of a Quality Outreach update sent to the projects involved. To learn more about the program and how to join, please check the Quality Outreach wiki page.
As of JDK 28, the jlink tool has a new security-properties plugin to configure security properties when creating a custom runtime. Use the --security-properties=filename option to supply a properties file. The plugin updates matching properties in the generated image's conf/security/java.security file and appends any new properties, so you can distribute a runtime with the settings your application needs.
For example, add the following setting to a file named network-security.properties:
networkaddress.cache.ttl=60
Then pass the file to jlink via --security-properties=network-security.properties as shown below:
"$JAVA_HOME/bin/jlink" \
--module-path "$JAVA_HOME/jmods" \
--add-modules java.base \
--security-properties=network-security.properties \
--output custom-runtime
The generated custom-runtime/conf/security/java.security file will contain networkaddress.cache.ttl=60. The plugin ignores comments in the supplied properties file and uses the last value for any repeated property.
If the file referenced by --security-properties option contains an include statement, the plugin places it at the end of the generated configuration. Furthermore, jlink copies the statement without requiring the file it names to exist on the build machine. You can supply that file later on the target system, where the generated runtime reads it as part of its security configuration. The original java.security file must contain neither duplicate properties nor include statements as either causes an error.
For more information, please check JDK-8381580.