本文主要研究一下openjdk的jvm.cfg文件html
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/jvm.cfgjava
# List of JVMs that can be used as an option to java, javac, etc. # Order is important -- first in this list is the default JVM. # NOTE that this both this file and its format are UNSUPPORTED and # WILL GO AWAY in a future release. # # You may also select a JVM in an arbitrary location with the # "-XXaltjvm=<jvm_dir>" option, but that too is unsupported # and may not be available in a future release. # -server KNOWN -client IGNORE
对于jdk8该文件在JAVA_HOME/jre/lib/目录下;其注释显示该配置文件用于配置java、javac可以使用的option,其中配置顺序很是重要,第一个为default JVM(
无论其是KNOWN仍是IGNORE;IGNORE仅仅是禁用VM option;ERROR则报错显示not supported
);能够看到这里-server是默认的,而-client则被忽略
/Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home/lib/jvm.cfgubuntu
-server KNOWN -client IGNORE
对于jdk九、十、十一、12该文件在JAVA_HOME/lib/目录下
对于jdk12,把-client移到前面oracle
-client IGNORE -server KNOWN
执行java -version显示以下jvm
java -version Error: missing `client' JVM at `/Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home/lib/client/libjvm.dylib'. Please install or use the JRE or JDK that contains these missing components.
能够看到对于mac的jdk12,把client设置为default则报错
-server KNOWN -client ERROR
执行java -client -version显示以下ide
java -client -version Error: client VM not supported
能够看到设置-client为ERROR,则报错显示not supported
java -version Error: could not open `/Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home/lib/jvm.cfg'
能够看到删除jvm.cfg,执行java -version则会报错
无论其是KNOWN仍是IGNORE;IGNORE仅仅是禁用VM option;ERROR则报错显示not supported
)