Linux RHEL 7.9 global environment vars

JulioAlblozano

New Member
Joined
Jun 2, 2021
Messages
4
Reaction score
0
Credits
31
I have a project with Jasperreports in a Redhat 7.9 linux environment and I need to use the function System.getenv("Var Name"), then I configure it in the bash_profile file, but when I use it it returns "null" , I have tried many things that they say in the forums, but nothing gives me result. I thank you for your help.

1622588832033.png

That way I configure them and I can see them, but in the report it always shows "null".

1622588970412.png
 


dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,017
Reaction score
690
Credits
5,145
.bashrc and .bash_profile are usually just for individual users, not global.

I would put this in /etc/environment
 
OP
J

JulioAlblozano

New Member
Joined
Jun 2, 2021
Messages
4
Reaction score
0
Credits
31
Thanks, I did that too but it didn't work for me, I don't know what I'm doing wrong. It does not take the var
 

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,017
Reaction score
690
Credits
5,145
Thanks, I did that too but it didn't work for me, I don't know what I'm doing wrong. It does not take the var

Are you "sourcing" the file after you edit it? (You may have to reboot)

What happens if you ...
echo $LABVANTAGE_HOMEICP
 
OP
J

JulioAlblozano

New Member
Joined
Jun 2, 2021
Messages
4
Reaction score
0
Credits
31
Generates the following

1622641641186.png


This is the environment file

1622641726340.png


and I have already restarted the system
 

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,017
Reaction score
690
Credits
5,145
It seems like, as far as the system in concerned, it's working.
Is this a python application? Is it in a virtual env?
 
OP
J

JulioAlblozano

New Member
Joined
Jun 2, 2021
Messages
4
Reaction score
0
Credits
31
No, it is Java a web portal with Jboss, the call of the variable is done with System.getenv("LABVANTAGE_HOMEICP"), with Linux machine on Azure Cloud
 

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,017
Reaction score
690
Credits
5,145
It's my understanding Java doesn't support global variables from the system.
You could have a global class, but you would still have to define them in code
or a config file for your app. (But then it wouldn't be global)
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Staff online

Members online


Latest posts

Top