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,774
Reaction score
1,378
Credits
11,903
.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
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
8,626
Reaction score
7,582
Credits
35,270

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,774
Reaction score
1,378
Credits
11,903
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,774
Reaction score
1,378
Credits
11,903
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,774
Reaction score
1,378
Credits
11,903
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)
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Top