Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting system properties

 
Patrick ODonnell
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Just a quick question. Can you set system properties from a Java Application? For example I want to set the JAVA_HOME property, how would this be done?
I know there is a,
System.setProperty()
But how is this used?
Thanks,
Patrick
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can change some properties local to java, but the change isn't permanent - it only lasts while the java app is running. It's like changing environment variables in a batch file - when the file is done running and the command window it launces exits, those settings get undone.
Setting JAVA_HOME would require some kind of access to the native environment variables - I don't think you can do this without using JNI, and then of course it's not portable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic