Tomcat sets environment variables
How to set the jdk version without changing the global environment variable
. As shown in the figure: My local environment has two versions of jdk.
My default is Oracle's jdk, so now I want to use zula's jdk in tomcat.
I need to do this:
- Find setclasspath.bat in the tomcat bin directory ( Linux corresponds to setclasspath.sh ) and enter it on the second line
set JAVA_HOME=XXX set JRE_HOME=XXX
- Corresponding to the Linux version is the input in setclasspath.sh
export JAVA_HOME=xxx
Set the environment variable of the setclasspath file and you can see that the setting takes effect when it is started.
Specify environment variables when executing the jar package
window 下
set JAVA_HOME=D:\ods\JavaZulu\zulu-8
set CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
set Path=%JAVA_HOME%\bin;
java -jar ./xxx.jar
…
还可以直接进入到 jdk的bin目录下,执行当前路径下的java.exe或者 Java 命令
Set Java global environment variables
1. If you are a root user, you can directly modify the /etc/profile file. After modifying the source /etc/profile
2. If you are a non-root user
1. View the user directory echo $HOME
2. Enter the user directory vi .bash_profile
3. Make the configuration take effect source .bash_profile