I use tomcat and I want to get an environment variable in my java code.
To set an environment variable, I use this bash command :
export TOMCAT_OPTS=-Dmy.var=foo
After it I start tomcat
./startup.sh (in bin folder of tomcat)
In my java code, I try to get this variable :
System.getEnv("my.var")
But it returns NULL.
How can I do that ?
I precise that if I use maven to launch tomcat and use eclipse environment tab, the variable is found ! But I need to launch tomcat like above in production mode.
EDIT: when using export MY_VAR directly it runs in local but not on my server...