I have a glassfish application server that is running under the glassfish user on CentOS 7.2. I have an application that has a deployed application that is needing a custom environment variable (e.g. export App_Home=/opt/App
).
The application is reading the environment variables in Java with within glassfish with System.getenv("App_Home")
.
I was able to get this to work by editing the service.
vi /etc/systemd/system/glassfish.service
Adding EnvironmentFile=/opt/MyApp/MyEnvironmentFile
and then in /opt/MyApp/MyEnvironmentFile
added
App_Home=/opt/MyApp
Is there a way of setting this environment variable with glassfish itself?
Or is there a better way of setting the system property variables instead of editing service files?
I also tried adding exports into the glassfish .bashrc (which is what shell the service seems to be running under) but that didn't seem to get passed down to the application.