• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to System Property In application

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I have a simple question that how can I set a System Property so that

it cant be accessible to the whole of my application.


Thanks in Advance to the Replier.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

There is only a single set of system properties, and that is accessible to all parts of an application (unless you want to fiddle with security managers, and introduce specific Permission objects for some parts of the code).

Maybe you can create a separate Properties object, and pass that to those parts of the code that are allowed to access it?

What is the problem you're trying to solve by doing this?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
there's a class may help you:
java.util.prefs.Preferences
In windows it manipulates registry,other OSs I don't know.

Maybe the easiest way is to set a static attribute.
Add one word and you've some properties accessibe all around your code while you import the class.
The trade off is however design issues.

Ofcourse you've some other strange ideas!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

there's a class may help you:
java.util.prefs.Preferences



But the Preferences API is accessible to all code in an application. How would you keep certain classes/packages from using it (without a security manager)?
 
mohsen fakhari
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Unfortunately I hadn't seen 't' in 'cant'.
I assumed it is about accessing a parameter from all the code
Thank you Mr.Bartender!
 
reply
    Bookmark Topic Watch Topic
  • New Topic