The default Java VM is set in your jvm.cfg
file. On Windows this is in your Java folder in C:\Program Files
, on Linux the path may vary.
On my Ubuntu 12.04 amd64 system with Oracle Java JDK7 installed via the Webupd8 ppa, the file is in /usr/lib/jvm/java-7-oracle/jre/lib/amd64
. For the default OpenJDK 6, the file is in /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/jvm.cfg
. Note that you need the JDK and not just the JRE installed.
Edit the jvm.cfg
that corresponds to your current default Java version (sudo nano /usr/lib/jvm/java-7-oracle/jre/lib/amd64/jvm.cfg
). Switch -server KNOWN
to -server IGNORE
and -client IGNORE
to -client KNOWN
.
This will make the -client flag
"known" to the java executable, and make it ignore the -server flag
, thus making it the default.
The original file (client vm as default):
# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
# ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
# 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
-hotspot ERROR
-classic WARN
-native ERROR
-green ERROR
Modified file (server vm as default):
# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
# ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
# 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
-server IGNORE
#-client IGNORE
-client KNOWN
-hotspot ERROR
-classic WARN
-native ERROR
-green ERROR
Now test to see if the change worked:
$ java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
Source