Category: Java/C++ Runtime


How is the "default" JVM picked at runtime?


As you probably know, the Codemesh runtime will normally attempt to pick a default JVM to load if you did not explicitly specify which JVM to use. We say "normally" because you can prohibit this behavior by using an xmog_jvm_loader singleton that prohibits default JVM use.

The selection algorithm that is used is relatively simple but you should use this documentation only as a guideline and not rely on the fact that it will remain unmodified. We will definitely tweak this algorithm over time, so the behavior that you observe when you run with a default JVM might change.

Here's the high-level overview:

  1. We look for an environment variable called JAVA_HOME. If set, we interpret it as refering to a directory that is the root directory of a JDK or JRE and try to identify a JVM relative to it.
  2. If JAVA_HOME is not set or if we can't find a valid JVM relative to it, we look in several wellknown directories for a Java distribution. The list of these directories is platform-specific and subject to change.
  3. Inside a potential Java distribution root directory, we use the following preference for selecting a JVM:





Finally, a word of caution: relying on a default JVM is not a good idea. We provide this feature because it can be a lifesaver in certain, relatively well-controlled intranet deployment scenarios, but in general you should always explicitly specify a JVM.

Remember: you can always implement your own custom algorithm for picking a "default" JVM to make sure that you only end up with a default JVM that satisfies your requirements. Specify your search criteria and use the configuration API to explicitly choose a found JVM.

Copyright 2006-2011 by Codemesh, Inc., ALL RIGHTS RESERVED

frequently asked questions
home products support customers partners newsroom about us contact us