• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Using absolute path bundle file

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,

Normally when i want to use a bundle file found in my classpath, i use this :

But i prefer to put the "languages" folder outside the jar, so is it possible to use a bundle file which is outside the classpath of my application ?, something like that :

Thanks . . .

 
Sheriff
Posts: 22504
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can use the getBundle method that takes a ClassLoader, and provide a URLClassLoader:
 
Hesham Gneady
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you're right Rob. This will help me to load other resources.
I tried it and it worked fine.

Thanks Rob
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.

Has anyone an idea?

Thanks
 
Marshal
Posts: 74341
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 26909
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Steffen Gallus
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

com.myexample.test



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" :/



Here is the code from Messages.java

 
Saloon Keeper
Posts: 13366
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should put your resources in a separate jar, and then put it on the classpath along with your main jar. You can then simply replace your language jar without touching the main application.
 
reply
    Bookmark Topic Watch Topic
  • New Topic