3

I got a warning message:

jvm uses the client vm, make sure to run java with the server vm for best performance by adding -server to the command line

In fact, when i run java -version i get:

OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-0ubuntu0.12.04.1)
OpenJDK Client VM (build 23.2-b09, mixed mode, sharing)

How does one go about and change OpenJDK's defaults to always start under the server VM?

2 Answers 2

4
+50

Assuming you have both the client and server VM installed, you just need to change the order of the lines in jvm.cfg to make -server first. You can find jvm.cfg like this:

find $(dirname $(dirname $(readlink -f $(which java)))) -name jvm.cfg

On my machine, it's /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/jvm.cfg.

2

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

2
  • This is partially incorrect: it's the order that determines the default JVM, not KNOWN or IGNORE. (The comments in that file indicate this: "Order is important -- first in this list is the default JVM".) IGNORE just silently disables a VM option. Your original jvm.cfg uses server as the default, and has client silently disabled, probably because it isn't present. Oct 16, 2012 at 20:10
  • This is the Ubuntu QA, no need for "On Windows do..." :) Oct 18, 2012 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.