the solution from Rob works, while i am in the EclipseIDE. But when i export it to jar and run this via JavaWebStart, it will not work.
In my JAR i have a messageFile named "messages_en.properties" (the default property file) with 3 key/value-pairs
I put into the "c:\temp" a messagefile named "messages_en_var1.properties" with only one key/value-pair, which shall override the existing key/value from the default properties
While i testing it in Eclipse IDE, the new Loader will find the extern message File, gets the one key which should be changed and takes for the other keys the default propteries.
But when i try it via JavaWebStart, it will not work. What happens is, that the application ONLY finds the resource file from the tmp-directory. The default properties will not be sourced.
Are you really using C:\tmp as the name of your file? When you use web start you are probably using absolute paths, so you will not find the file. Is there a copy of that file in your .jar file? What is its PATH and location?
More to the point, when you run the application via Web Start it's going to be run on somebody else's computer. They don't have access to your C: drive. So if you plan to run your application that way, you should put the ResourceBundle in the jar file and access it in the usual way, as a resource.
I am sorry for my explaination, i tried to keep it simple with the given example...
What i have:
A project with the following structure
That means, the messages.properties will be the default. When i have a Locale with en (Locale.English), then he will pick the "messages_en.properties" and when there is missing one key, they will be fallback to default "messages.properties" (for only this key/value)
The message*.properties are in the jar-File and will be distributed. So everyone with access can get it
All works very fine .
Now, i want the ability to change/add some Strings without touching the jar-files (i cant touch them after distribution cause of signing the jar-files .....)
Therefore, i tried to put "messages_de.properties" in a web-path ( http://somedomain.com/jws-stuff/com/myexample/test/ )
When i start it with eclipse, he tries to find the messages_de.properties. I give the URLClassloader the "start-folder" (http://somedomain.com/jws-stuff/) and he will find, in dependency to the BundleName, the following package-structure. Therefore i need to create folders like "http://somedomain.com/jws-stuff/com/myexample/test/"
He use the given key/value pairs specified in the "de.properties" and will fallback to the "messages.properties" in the project, when a key will not be founde.
It works very fine !
But when i export it with the new ClassLoader to a jar-file and start it with JNLP , they will only find the messages_de.properties on the server and DONT fall back to "messages.properties" :/