Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to System Property In application

 
Muhammad Umair Sheikh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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?
 
mohsen fakhari
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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: 42967
73
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic