• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get Environment variable on linux (ubuntu)  RSS feed

 
Peter Benda
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am doing the next and get null :

i tried to put it in:
~/.bashrc
env

the project runs under wildfly/jboss.
why i get always null?
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the documentation about System#getenv(String) say?
What do you get from the terminal when you write this?
echo $myVar1
How did you set the myVar1 variable in the first place? Have you got such an environment variable at all? Have you spelt it correctly, remembering that Linux systems are usually CaSe SeNsItIvE?

Moving to our Linux forum.
 
Peter Benda
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i do echo $myVar1 i see the value
when i do printenv i see the definition in the env
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us the instructions to the terminal and the values you are getting printed.
 
Peter Benda
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That isn't your environment file; it is root's. Do you have one not belonging to root?
 
Peter Benda
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no.
 
Ron McLeod
Bartender
Posts: 1602
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:That isn't your environment file; it is root's. Do you have one not belonging to root?

Peter Benda wrote:no.

It might be interesting to iterate through and print out the runtime environment variables returned by System#getenv() to see what environment you have now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!