If you know for sure that none of the common frameworks are used, for example, the Spring Framework, and you have code that strictly searches for environment variables, then you must set environment variables outside any of the usual configuration files before the Java process starts that awaits him. After starting the Java process, the environment variables are read-only and are final for the process.
Note. . If you need environment variables for the whole system, use / etc / profile, / etc / bash_profile, / etc / environment, etc. Keep in mind that setting variables to these global locations requires restarting Node Manager from a new login. You do not need to reboot, but profile / environment files usually only exit when you log in.
For applications in only one domain or node, environment variables must be in startup scripts for the server (s). Editing setDomainEnv. [Sh | cmd] or run (managed) Weblogic. [Sh | cmd] is the best option for setting WebLogic environment variables.
However, if the application uses Spring, the system properties and environment variables are combined. System properties are very welcome and easier to maintain and control.
Link: What is best suited for setting java, -D, or System.setProperty () system properties?
Weblogic Domain Environment Variables
One of the places to set both system properties and environment variables is to edit the script domain environment used to run all nodes or servers that use the same installation and the WebLogic server domain. Inside <weblogic_domain> /bin/setDomainEnv.sh(setDomainEnv.cmd on windows), for environment variables, just add them near the top and add comments to document their use.
export CUSTOM_VAR="test"
For system properties, you can add command line arguments that will be added to each server by adding a line for EXTRA_JAVA_PROPERTIES at the top of the file next to the WL_HOME definition, but after functions and comments.
EXTRA_JAVA_PROPERTIES="-Denv=TEST" export EXTRA_JAVA_PROPERTIES WL_HOME="/appl/oracle/middleware/wls/12.1.2.0.0/wlserver" export WL_HOME
Weblogic Node Special Environment Variables
If you need different environment variables for each Node launched by the same Node manager, you will have to configure startup scripts a bit. In this case, edit <weblogic_domain> / bin / startManagedWeblogic. [sh | cmd] and paste some scripting logic after _export SERVER_NAME_. This way you can manage settings based on SERVER_NAME etc.
Tip. Windows environment variables are not case sensitive using System.getenv (..).