[Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Inosh Perera
Hi all,
Using java code, I'm trying to retrieve an environment variable defined in
the OS(Ubuntu). When I define a variable in bashrc / bash_profile and **echo
$SOME_VARIABLE** in  the terminal, it shows it properly. But when I'm
accessing it with Java, using System.getenv() , this variable doesn't
appear. What could be the reason?

MapString, String variables = System.getenv();

for (Map.EntryString, String entry : variables.entrySet())
 {
   String name = entry.getKey();
   String value = entry.getValue();
   System.out.println(name + = + value);
}

Regards,
Inosh
-- 
Inosh Perera
Software Engineer, WSO2 Inc.
Tel: 0785293686
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Rajith Vitharana
Hi Inosh,

Have you tried restarting the machine?

Thanks,


On Mon, Jul 14, 2014 at 1:35 PM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 Using java code, I'm trying to retrieve an environment variable defined in
 the OS(Ubuntu). When I define a variable in bashrc / bash_profile and **echo
 $SOME_VARIABLE** in  the terminal, it shows it properly. But when I'm
 accessing it with Java, using System.getenv() , this variable doesn't
 appear. What could be the reason?

 MapString, String variables = System.getenv();

 for (Map.EntryString, String entry : variables.entrySet())
  {
String name = entry.getKey();
String value = entry.getValue();
System.out.println(name + = + value);
 }

 Regards,
 Inosh
 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Inosh Perera
Hi Rajitha,

Yes, I also tried couple of other ways.

Thanks,


On Mon, Jul 14, 2014 at 1:40 PM, Rajith Vitharana raji...@wso2.com wrote:

 Hi Inosh,

 Have you tried restarting the machine?

 Thanks,


 On Mon, Jul 14, 2014 at 1:35 PM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 Using java code, I'm trying to retrieve an environment variable defined
 in the OS(Ubuntu). When I define a variable in bashrc / bash_profile and
 **echo $SOME_VARIABLE** in  the terminal, it shows it properly. But
 when I'm accessing it with Java, using System.getenv() , this variable
 doesn't appear. What could be the reason?

 MapString, String variables = System.getenv();

 for (Map.EntryString, String entry : variables.entrySet())
  {
String name = entry.getKey();
String value = entry.getValue();
System.out.println(name + = + value);
 }

 Regards,
 Inosh
 --
  Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/




-- 
Inosh Perera
Software Engineer, WSO2 Inc.
Tel: 0785293686
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Rajith Vitharana
Hi Inosh,

Try putting it ~/.bashrc. I have done a similar thing. It worked when the
variable is defined in ~/.bashrc and restarting the machine.

Thanks,


On Mon, Jul 14, 2014 at 1:43 PM, Inosh Perera ino...@wso2.com wrote:

 Hi Rajitha,

 Yes, I also tried couple of other ways.

 Thanks,


 On Mon, Jul 14, 2014 at 1:40 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Have you tried restarting the machine?

 Thanks,


 On Mon, Jul 14, 2014 at 1:35 PM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 Using java code, I'm trying to retrieve an environment variable defined
 in the OS(Ubuntu). When I define a variable in bashrc / bash_profile and
 **echo $SOME_VARIABLE** in  the terminal, it shows it properly. But
 when I'm accessing it with Java, using System.getenv() , this variable
 doesn't appear. What could be the reason?

 MapString, String variables = System.getenv();

 for (Map.EntryString, String entry : variables.entrySet())
  {
String name = entry.getKey();
String value = entry.getValue();
System.out.println(name + = + value);
 }

 Regards,
 Inosh
 --
  Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/




 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686




-- 
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Harsha Kumara
Hi Inosh.
Did you export that variable in bashrc?
Thanks,
Harsha


On Mon, Jul 14, 2014 at 1:50 PM, Rajith Vitharana raji...@wso2.com wrote:

 Hi Inosh,

 Try putting it ~/.bashrc. I have done a similar thing. It worked when
 the variable is defined in ~/.bashrc and restarting the machine.

 Thanks,


 On Mon, Jul 14, 2014 at 1:43 PM, Inosh Perera ino...@wso2.com wrote:

 Hi Rajitha,

 Yes, I also tried couple of other ways.

 Thanks,


 On Mon, Jul 14, 2014 at 1:40 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Have you tried restarting the machine?

 Thanks,


 On Mon, Jul 14, 2014 at 1:35 PM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 Using java code, I'm trying to retrieve an environment variable defined
 in the OS(Ubuntu). When I define a variable in bashrc / bash_profile and
 **echo $SOME_VARIABLE** in  the terminal, it shows it properly. But
 when I'm accessing it with Java, using System.getenv() , this variable
 doesn't appear. What could be the reason?

 MapString, String variables = System.getenv();

 for (Map.EntryString, String entry : variables.entrySet())
  {
String name = entry.getKey();
String value = entry.getValue();
System.out.println(name + = + value);
 }

 Regards,
 Inosh
 --
  Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/




 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Harsha Kumara
Software Engineer, WSO2 Inc.
Mobile: +94775505618
Blog:harshcreationz.blogspot.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Chamil Jeewantha
[1] may helps to you. BTW, the code you have written gives expected result
within Command Line simple java program.

[1]
http://stackoverflow.com/questions/13748367/system-getenv-does-not-list-all-the-environment-variables


On Mon, Jul 14, 2014 at 1:51 PM, Harsha Kumara hars...@wso2.com wrote:

 Hi Inosh.
 Did you export that variable in bashrc?
 Thanks,
 Harsha


 On Mon, Jul 14, 2014 at 1:50 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Try putting it ~/.bashrc. I have done a similar thing. It worked when
 the variable is defined in ~/.bashrc and restarting the machine.

 Thanks,


 On Mon, Jul 14, 2014 at 1:43 PM, Inosh Perera ino...@wso2.com wrote:

 Hi Rajitha,

 Yes, I also tried couple of other ways.

 Thanks,


 On Mon, Jul 14, 2014 at 1:40 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Have you tried restarting the machine?

 Thanks,


 On Mon, Jul 14, 2014 at 1:35 PM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 Using java code, I'm trying to retrieve an environment variable
 defined in the OS(Ubuntu). When I define a variable in bashrc /
 bash_profile and **echo $SOME_VARIABLE** in  the terminal, it shows
 it properly. But when I'm accessing it with Java, using System.getenv() ,
 this variable doesn't appear. What could be the reason?

 MapString, String variables = System.getenv();

 for (Map.EntryString, String entry : variables.entrySet())
  {
String name = entry.getKey();
String value = entry.getValue();
System.out.println(name + = + value);
 }

 Regards,
 Inosh
 --
  Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/




 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Harsha Kumara
 Software Engineer, WSO2 Inc.
 Mobile: +94775505618
 Blog:harshcreationz.blogspot.com

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
K.D. Chamil Jeewantha
Associate Technical Lead
WSO2, Inc.;  http://wso2.com
Mobile: +94716813892
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Inosh Perera
Hi Rajitha,
Putting it in bash_profile worked. It was not defined properly before.

Thank you


On Mon, Jul 14, 2014 at 1:51 PM, Harsha Kumara hars...@wso2.com wrote:

 Hi Inosh.
 Did you export that variable in bashrc?
 Thanks,
 Harsha


 On Mon, Jul 14, 2014 at 1:50 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Try putting it ~/.bashrc. I have done a similar thing. It worked when
 the variable is defined in ~/.bashrc and restarting the machine.

 Thanks,


 On Mon, Jul 14, 2014 at 1:43 PM, Inosh Perera ino...@wso2.com wrote:

 Hi Rajitha,

 Yes, I also tried couple of other ways.

 Thanks,


 On Mon, Jul 14, 2014 at 1:40 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Have you tried restarting the machine?

 Thanks,


 On Mon, Jul 14, 2014 at 1:35 PM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 Using java code, I'm trying to retrieve an environment variable
 defined in the OS(Ubuntu). When I define a variable in bashrc /
 bash_profile and **echo $SOME_VARIABLE** in  the terminal, it shows
 it properly. But when I'm accessing it with Java, using System.getenv() ,
 this variable doesn't appear. What could be the reason?

 MapString, String variables = System.getenv();

 for (Map.EntryString, String entry : variables.entrySet())
  {
String name = entry.getKey();
String value = entry.getValue();
System.out.println(name + = + value);
 }

 Regards,
 Inosh
 --
  Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/




 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Harsha Kumara
 Software Engineer, WSO2 Inc.
 Mobile: +94775505618
 Blog:harshcreationz.blogspot.com




-- 
Inosh Perera
Software Engineer, WSO2 Inc.
Tel: 0785293686
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DEV] Retrieving an environment variable from Java

2014-07-14 Thread Kasun Dissanayake
Hi Inosh,

It works for me when you add it on root .bashrc like the following

SYNAPSE_HOME=/home/user/Team/synapse-2.1.0
export SYNAPSE_HOME
PATH=$PATH:$SYNAPSE_HOME/bin
export PATH

And you shouldn't restart it. It's working fine

Cheers


On Mon, Jul 14, 2014 at 1:51 PM, Harsha Kumara hars...@wso2.com wrote:

 Hi Inosh.
 Did you export that variable in bashrc?
 Thanks,
 Harsha


 On Mon, Jul 14, 2014 at 1:50 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Try putting it ~/.bashrc. I have done a similar thing. It worked when
 the variable is defined in ~/.bashrc and restarting the machine.

 Thanks,


 On Mon, Jul 14, 2014 at 1:43 PM, Inosh Perera ino...@wso2.com wrote:

 Hi Rajitha,

 Yes, I also tried couple of other ways.

 Thanks,


 On Mon, Jul 14, 2014 at 1:40 PM, Rajith Vitharana raji...@wso2.com
 wrote:

 Hi Inosh,

 Have you tried restarting the machine?

 Thanks,


 On Mon, Jul 14, 2014 at 1:35 PM, Inosh Perera ino...@wso2.com wrote:

 Hi all,
 Using java code, I'm trying to retrieve an environment variable
 defined in the OS(Ubuntu). When I define a variable in bashrc /
 bash_profile and **echo $SOME_VARIABLE** in  the terminal, it shows
 it properly. But when I'm accessing it with Java, using System.getenv() ,
 this variable doesn't appear. What could be the reason?

 MapString, String variables = System.getenv();

 for (Map.EntryString, String entry : variables.entrySet())
  {
String name = entry.getKey();
String value = entry.getValue();
System.out.println(name + = + value);
 }

 Regards,
 Inosh
 --
  Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/




 --
 Inosh Perera
 Software Engineer, WSO2 Inc.
 Tel: 0785293686




 --
 Rajith Vitharana

 Software Engineer,
 WSO2 Inc. : wso2.com
 Mobile : +94715883223
 Blog : http://lankavitharana.blogspot.com/

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




 --
 Harsha Kumara
 Software Engineer, WSO2 Inc.
 Mobile: +94775505618
 Blog:harshcreationz.blogspot.com

 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev




-- 
Kasun Dissanayake
Software Engineer
WSO2 Inc.
Lean | Enterprise | Middleware
Tel - +94 77 086 2860
Skype - kasun.dissanayake4
LinkedIn - lk.linkedin.com/in/kasundis/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev