JAVA_TOOL_OPTIONS和_JAVA_OPTIONS
2021-02-16 18:21
标签:file tom lin enc visual centos jvisualvm MIXED mode Linux 使用export设置环境变量时,如果变量值有空格需要用引号 JAVA_TOOL_OPTIONS和_JAVA_OPTIONS 标签:file tom lin enc visual centos jvisualvm MIXED mode 原文地址:https://www.cnblogs.com/dingzk/p/12703555.html
结果(不完善):
JAVA_OPTS是某些软件如tomcat的启动脚本设置的
_JAVA_OPTIONS 和 JAVA_TOOL_OPTIONS ,如果只有一个存在,则java/javac会使用有值的设置;
如果同时存在,会先检测到JAVA_TOOL_OPTIONS,java命令使用所有变量设置的值;
_JAVA_OPTIONS中同名的值会覆盖JAVA_TOOL_OPTIONS中设置的值(如JVM堆大小),使用jvisualvm查看运行的程序可以发现。
但不确定上述两个变量哪个对java或javac是特定的。
测试用例:
```
[root@centos6 ~]# export JAVA_OPTS=foobar
[root@centos6 ~]# export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
[root@centos6 ~]# export _JAVA_OPTIONS="-Xmx512m -Xms64m"
[root@centos6 ~]# java -version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Picked up _JAVA_OPTIONS: -Xmx512m -Xms64m
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
[root@centos6 ~]# javac -version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Picked up _JAVA_OPTIONS: -Xmx512m -Xms64m
javac 1.8.0_91
```
--------
```
[root@centos6 ~]# export JAVA_OPTS=foobar
[root@centos6 ~]# export JAVA_TOOL_OPTIONS="-Xmx512m -Xms64m"
[root@centos6 ~]# export _JAVA_OPTIONS=-Dfile.encoding=UTF-8
[root@centos6 ~]# java -version
Picked up JAVA_TOOL_OPTIONS: -Xmx512m -Xms64m
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
[root@centos6 ~]# javac -version
Picked up JAVA_TOOL_OPTIONS: -Xmx512m -Xms64m
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
javac 1.8.0_91
```
--------
```
[root@centos6 ~]# export JAVA_TOOL_OPTIONS="-Xmx256m -Xms64m"
[root@centos6 ~]# export _JAVA_OPTIONS="-Xmx512m -Xms64m"
[root@centos6 ~]# java -version
[root@centos6 ~]# javac -version
```
--------
```
[root@centos6 ~]# export JAVA_TOOL_OPTIONS="-Xmx512m -Xms64m"
[root@centos6 ~]# export _JAVA_OPTIONS="-Xmx256 -Xms64m"
[root@centos6 ~]# java -version
[root@centos6 ~]# javac -version
```
--------
```
[root@centos6 ~]# export JAVA_TOOL_OPTIONS="-Xmx256 -Xms64m"
[root@centos6 ~]# export _JAVA_OPTIONS=
[root@centos6 ~]# java -version
[root@centos6 ~]# javac -version
```
--------
```
[root@centos6 ~]# export JAVA_TOOL_OPTIONS=
[root@centos6 ~]# export _JAVA_OPTIONS="-Xmx256 -Xms64m"
[root@centos6 ~]# java -version
[root@centos6 ~]# javac -version
```
上一篇:二叉树的所有路径与旋转数组
下一篇:Java输入输出
文章标题:JAVA_TOOL_OPTIONS和_JAVA_OPTIONS
文章链接:http://soscw.com/index.php/essay/56214.html