Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I get the environment variables in my java code.  RSS feed

 
Shanmu Arumugam
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone please tell me how to get the environment variables(Webspherer 6.0) in the java code. I tried using System.getProperties(). but it is not listing out those variables.

Thanks
Shanmu
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not crosspost. You've already asked in the Websphere forum.
http://www.coderanch.com/t/78190/Websphere/do-environment-variables-java-code
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, please do not cross post. I closed the one in Webspehere.

Please give us information on whether the variable is defined in an xml file and which one, or is it being declared at the command line with something like -Dmy.var.name=Hello

Mark
 
Shanmu Arumugam
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Apologize me, I did't know where to post exactly.

I just want to declare a variable in Admin console under either "Environment->Websphere variables" or "Naming->Name Space Bindings" . Eventualy, I want that value of that variable in my java code. I read somewhere, System.getProperty() would get those value. But that doesn't work. Please let me know , is any other way?.. Can we use context lookup?

Thanks
Shanmu
 
JigaR Parekh
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which JDK you are using?
If you are using 1.4 then there is problem with System.getProperties, you have to excplicitly specify with java command for -D

If you are using 5.0 then environmental variable should be visible.

JigaR
 
Shanmu Arumugam
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

sorry, I did't get you. Can you please explain.
 
Paul Clapham
Sheriff
Posts: 22487
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shanmu chn", I think you must have missed reading our policy on display names when you signed up here. We do require members to have valid display names.

Display names must be at least two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!