Home News Products Online Demo Shop Contact CSCare Inc.

Sales & Ordering

How to choose the desired Java VM for JWinSvc.

JWinSvc NT Service Java wrapper launches Java applications in a Java Virtual Machine created via JNI interface. Runtime library jvm.dll implements this interface (javai.dll in older Java releases).

Generally, Java applications run with Java Runtime Environment's runtime library. However, there may be applications or services that require to run with Java Development Kit's runtime library as it provides some additional features in comparison with Java Runtime Environment's runtime library.

There are several ways how to specify the preferred runtime library to be loaded when launching an application.

Command Line Parameters

In JWinSvc, the following two command line parameters are available, using which the runtime library can be specified:

1./runtimelib:<path> – contains the path to runtime library

Example:

JWinSvc "My Service" /start /runtimelib:"C:\jdk1.3.1\jre\bin\classic\jvm.dll"

With 'runtimelib' parameter, 'My Service' is started and jvm.dll is loaded from the specified location. If the runtime library is not found on the defined path, an error occurs stating that the specified runtime library cannot be found.

2./javahome:<path> – contains the path to Java installation base directory

Example:

JWinSvc "My Service" /start /javahome:"C:\jdk1.3.1"

In this case, 'My Service' application is started and the first runtime library found in the 'C:\jdk1.3.1' directory (including its subdirectories) will be loaded. This command line parameter is more general and gives a wider range in terms of searching for runtime libraries. The type of the runtime library can be specified if necessary, using the <java type> command line switch (–classic, –server, –hotspot; it will be described later) as follows:

JWinSvc "My Service" /start /javahome:"C:\jdk1.3.1" java –server

Here, 'My Service' application is started using the 'server' type of jvm.dll runtime library found within the scope of the 'C:\jdk1.3.1' directory. If no such runtime library is found, then an error occurs stating that the preferred ('server' type in this case) runtime library is not available.

How is JWinSvc Searching for Runtime Library

While launching an application with JWinSvc, it is searching for a runtime library in the following order:
  1. If the command line parameter /runtimelib:<path> is specified, JWinSvc will try to load the defined runtime library. If the runtime library is not found, you will be informed about it by an error message.
  2. If the command line parameter /javahome:<path> is specified, JWinSvc will try to load a runtime library on the defined path extended by the <relative path> parameter which further specifies the locations where the runtime library may be located. The <relative path> parameter is searched in the following order:
    1. \bin\<jvm type>\jvm.dll
    2. \bin\javai.dll
    3. \jre\bin\<jvm type>\jvm.dll
    4. \jre\bin\javai.dll
    <jvm type> parameter specifies the supported Java byte code interpreters given by Java installation and are listed in the jvm.cfg file located in Java home directory's lib or lib\i386 subdirectory. These interpreters differ in terms of usage optimization. There are three types of Java interpreters: 'classic' – the most stable but slightly slower interpreter than the next ones; 'server' – designed for server applications; and 'hotspot' – designed for applets.
    JWinSvc takes the first jvm type in the order as listed in jvm.cfg.

    Note: If you prefer a different jvm type to be selected, you can specify a Java option when launching your application, as for example:

    JWinSvc "My Service" /install java –server –jar ap.jar

    where the '-server' option can be also '-classic' or '-hotspot'.

    If no runtime library is found on the defined path, you will be informed about it by an error message.

    Note: In case of specifying the both command line parameters at the same time, the /runtimelib parameter has higher priority, therefore the /javahome parameter will be ignored.

  3. If no command line parameter is specified, JWinSvc will try to search for <JAVA_HOME environment variable> which specifies the path to the Java home directory. If it exists, JWinSvc performs the same way as if the '/javahome' command line parameter was used.
  4. If the JAVA_HOME environment variable is set but no runtime library can be found on the defined path, an error message will inform you about it.

    In case of not having the JAVA_HOME environment set, JWinSvc continues searching in locations in the order as follow:

  5. <current working directory><relative path> – JWinSvc will be searching for a runtime library in the current working directory extended by the relative paths as described earlier. If no runtime library is found, JwinSvc continues searching in the following item:
  6. 'HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Development Kit' registry key – JWinSvc checks the 'CurrenVersion' value, according to this value JWinSvc goes to the appropriate key (e.g. 1.3), and in that key, it takes the path defined in the 'RuntimeLib' value and performs the same way as if the '/runtimelib' command line parameter was used. If no runtime library is found on the defined path, the following item will be searched:
  7. 'HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Development Kit' registry key – 'CurrenVersion' value will be checked, according to this value JWinSvc goes to the appropriate key (e.g. 1.3), and in that key, it takes the path defined in the 'JavaHome' value and performs the same way as if the '/javahome' command line parameter was used. If no runtime library is found on the defined paths, the following item will be searched:
  8. 'HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment' registry key – JWinSvc checks the 'CurrenVersion' value, according to this value, JWinSvc goes to the appropriate key (e.g. 1.3), and in that key, it takes the path defined in the 'RuntimeLib' value and performs the same way as if the '/runtimelib' command line parameter was used. If no runtime library is found on the defined path, the following item will be searched:
  9. 'HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment' registry key – 'CurrenVersion' value will be checked, according to this value JWinSvc goes to the appropriate key (e.g. 1.3), and in that key, it takes the path defined in the 'JavaHome' value and performs the same way as if the '/javahome' command line parameter was used.

If no runtime library is found after all, JWinSvc will report an error stating that no runtime library is available on the system.

Trap Console JWinSvc