Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted
+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.

share|improve this answer

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

share|improve this answer
    
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. –  Trevor Robinson Oct 16 '12 at 20:10
    
This is the Ubuntu QA, no need for "On Windows do..." :) –  montrealmike Oct 18 '12 at 13:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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