-
We are trying to load resource bundles from arbitrary paths, as we need to load some files dynamically at runtime. Following example creates an URLClassLoader from a file and loads a ResourceBundle. It works fine when running as jar: // from https://stackoverflow.com/questions/1172424/how-to-load-a-resource-bundle-from-a-file-resource-in-java
File file = new File(".");
URL[] urls = { file.toURI().toURL() };
ClassLoader loader = new URLClassLoader(urls);
ResourceBundle rb = ResourceBundle.getBundle("messages", Locale.ENGLISH, loader); When running as native image it only works when files are on available on classpath and configured according to https://www.graalvm.org/jdk21/reference-manual/native-image/dynamic-features/Resources/. However, it fails when we try to load ResourceBundles from paths outside classpath with MissingResourceException. We tried adding Is loading ResourceBundles outside classpath supported for native image or is it not possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @ls-bit, I'm afraid loading ResourceBundles outside classpath won’t work with Native Image. |
Beta Was this translation helpful? Give feedback.
-
We plan to remove the flag |
Beta Was this translation helpful? Give feedback.
We plan to remove the flag
LocalizationOptimizedMode
. Once this is done, we should be able to support this case.