This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Can JWS application read from a properties file? Or do I need to use persistance service APIs? My current stand-alone application reads lot of values from the properties file, so I was wondering if it would possible to let it stay that way. - Manish
hi Manish Can JWS application read from a properties file?
yes. why not? i don't see any problem in doing that. i guess u r reading property files via loadProperties() or some standard java mechanism right? u may 've to sign the application jar tho if u want to store that properties file on the user machine .... regards maulin
We don't want to sign the jar file. So I did find <property> tag of JNLP, but unfortunately it is not working either. I did try using <property name="jnlp.xyz" value="somevalue"> and <property name="javaws.xyz" value="somevalue">, but it gives me security exception when I try to read this property. So at the moment I am reading the properties file from the server via URLConnection. Is there a better way of doing this? TIA, - Manish
Joined: Nov 04, 2001
hi Manish i played w/ it more and i find following, the problem is we can use property tag of the jaws only if we have signed the jar files. the reason being, property tag in JNLP is just a declaration that we want to make some "key" , "value" visible via System.getProperty() or System.getProperties(). Now, jaws will go to actually write the System property with name "key" and value "value" upon dowloading the jar file. This means that we have to have "write" permission for the property on the system which is by default not available thus , JNLP property tag doesn't work for us unless we sign the application jar. i tried to sign in and it works. though we have to specify security tag in JNLP after signing the application as you might know already. so, the solution u adopted seems okay. the only disadvantage u 'll have is- u won't be able to run ur application off line as it will require URLCOnnection. u can probably adapt some mechanism using JNLP Persistence API to store the properties u read in "muffins" and then use them while u r offline.... regards maulin
Joined: Nov 04, 2001
hi Manish also, i found another tweak. that is- if ur properties are really not java system properties like line.separator etc and user custom property like "userName" etc then u can use "arguments" JNLP tag and pass it to main class in the jar following a convention u define. e.g. if u had a property name jnlp.name and jnlp.server which u wanted to transfer to the application then u can write,
and then in main class u can interpret the arguments and prepare hashtable of the properties. this is little more work than using System.getProperty() but it might be feasible for u... regards maulin
AFAIK, if you prepend property name with jnlp or javaws, then even an unsigned JWS application can read (only) these properties, it is also mentione on Sun site somewhere. But for some reasons, it is not working. I have also resorted to using arguments as a woraround. My application is a very much a client server application and uses servlets heavily to do lots of things. So reading from the server is fine.