5 Migrating Applications to the JRockit JDK

This chapter describes how to migrate Java applications developed on other JDKs to the JRockit JDK to ensure optimal performance during run time.

This chapter contains the following topics:

Note:

Successful migration to the Oracle JRockit JDK often depends as much on the application being migrated as on the JVM. Oracle welcomes suggestions based upon your experiences with migrating applications to the Oracle JRockit JDK.

Migrating an application to the JRockit JDK requires you to make a few minor environmental changes and follow some simple coding guidelines.

This chapter provides instructions and tips to help you complete the migration process. It also describes the benefits of migration and problems that you might encounter during migration, and it describes some best Java coding practices to ensure that your application runs successfully after migrating it to the JRockit JDK.

The JRockit JDK is the default JDK shipped with Oracle WebLogic Server. Although there are other JDKs available in the market, Oracle recommends that you use JRockit JDK with Oracle products.

You can migrate applications for all platforms for which Oracle WebLogic Server is supported with the JRockit JDK. For more information, see the Oracle JRockit JDK Supported Configurations at http://www.oracle.com/technology/software/products/ias/files/fusion_certification.html.

5.1 Support for Migration Problems

If you have any problems while migrating an application to the JRockit JDK, contact Oracle through My Oracle Support.

When you contact Oracle for support, provide as much information as possible about the problem; for example, provide the following information:

  • Hardware

  • Operating system and its version

  • Program you are attempting to migrate

  • Stack dumps (if any)

  • A small code example that reproduces the error

  • Copies of any *.dump and *.mdmp/core process memory dump files (on Windows, the dump files they are stored as *.mdmp; on Linux and Solaris as core or core.*)

5.2 Migration Tasks

The following topics describe the tasks you must perform to migrate applications from a third-party JDK to the Oracle JRockit JDK.

5.2.1 Make Necessary Changes in the Application Environment

Note:

The changes described in this section apply primarily to Oracle WebLogic Server. If you are working with other Java applications, you must change the scripts and environments according to how that application is set up.

To migrate from a third-party JDK to the JRockit JDK, make the following changes to the application environment.

  • Set the JAVA_HOME environment variable in WL_HOME/common/commEnv.cmd (or .sh) to the appropriate path.

  • Set the JAVA_VENDOR environment variable in WL_HOME/common/commEnv.cmd (or .sh) to BEA.

  • If you use a start-up script, remove any command-line options that are specific to third-party JVMs. If possible, replace the third-party options with the Oracle JRockit JVM-specific equivalents (for example, -Xns). Other flags that might need to be changed include MEM_ARGS and JAVA_VM.

    For more information about the command-line options that the Oracle JRockit JVM supports, see the Oracle JRockit Command-Line Reference:

  • Change config.xml to point the default compiler settings to the javac compiler in the JRockit JDK.

    Note:

    Ensure that your application is developed to run on the Oracle JRockit JDK according to the guidelines described in the Oracle JRockit Application Development Guide.

5.2.2 Tune the JRockit JVM for Optimal Performance

After you migrate your application to the JRockit JDK, tune the JVM for optimal performance. For example, you might want to specify a different startup heap size or set custom garbage collection parameters. For more information about tuning the JRockit JVM, see Oracle JRockit Performance Tuning Guide.

The nonstandard command-line options (preceded with -X) are critical tools for tuning a JVM at startup. These options change the behavior of the JRockit JVM to suit the requirements of different Java applications. If you are migrating an application to the JRockit JDK, Oracle recommends that you become familiar with the nonstandard options available to you. For more information, see the Oracle JRockit Command-Line Reference.

Note:

The names of nonstandard options might not be the same from JVM to JVM. For example, in the JRockit JVM the name of the nonstandard option to set the nursery in generational concurrent and generational parallel garbage collectors is -Xns, whereas, in the HotSpot JVM, the name of the equivalent option is -XX:NewSize.

Nonstandard options are subject to change at any time.

5.3 Testing the Application

After performing the migration tasks described earlier, test your application on the JRockit JVM.

Some important reasons for testing are:

  • You might find bugs in your application that do not occur on the HotSpot JVM; for example, synchronization problems.

  • You might have used third-party class libraries that do not follow the Java specifications and rely on HotSpot-specific classes or behavior.

  • You might have used third-party class files that are not correct. The JRockit JVM enforces verification rigorously.

To test your application on the JRockit JVM, run the application against any test scripts or benchmarks that are appropriate for that application. If any problems occur, handle them as you typically would for the specific application.

5.4 Replicating Tools Supplied with the HotSpot JDK

The following J2SE tools, normally available with the HotSpot JDK, are not shipped with the JRockit JDK:

  • jinfo

  • jhat

  • jmap

  • jsadebugd

  • jstack

The JRockit JDK provides internal tools that are equivalent to most of the HotSpot tools. Table 5-1 lists the HotSpot JDK tools and their JRockit JDK equivalents. Some tools require using the jrcmd feature. For more information, see Oracle JRockit JDK Tools.

Table 5-1 JRockit JDK and HotSpot JDK: Tool Equivalents

HotSpot Tool Shipped with JRockit JDK Oracle JRockit Equivalent

jinfo

No

jrcmd pid print_properties

jrcmd pid command_line

jmap

No

JRockit Memory Leak Detector (see Oracle JRockit JDK Tools

The following diagnostic commands:

  • jrcmd pid print_object_summary

  • jrcmd pid verbose_referents

  • jrcmd pid heap_diagnostics

jsadebugd

No

None

jhat

Yes

jhat works with the JRockit JVM.

You can also use the JRockit Memory Leak Detector and the JRockit Flight Recorder.

jstack

No

jrcmd pid print_threads

jps

Yes

jrcmd

jstat

Yes

jstat works with the JRockit JVM.

You can also use the JRockit Flight Recorder and the JRockit Management Console in Oracle JRockit Mission Control (see Oracle JRockit JDK Tools).

jstatd

Yes

jstatd works with the JRockit JVM.

jconsole

Yes

jconsole works with the JRockit JVM.

You can also use the JRockit Management Console in Oracle JRockit Mission Control (see Oracle JRockit JDK Tools).

jrunscript

Yes

jrunscript works with the JRockit JVM.


5.5 Command-line Option Compatibility Between the JRockit and HotSpot JVMs

This section describes the compatibility between the important and commonly used command-line options available when running the JRockit JVM with the options when running the HotSpot JVM.

Table 5-2 lists the options that have the same name in both the HotSpot and JRockit JVMs and but have different functions.

Table 5-2 Same Name, Different Function

Option HotSpot JVM Function JRockit JVM Function

-Xms

Sets the initial size of the heap

Sets the initial and minimum size of the heap

For more information, see the Oracle JRockit Command-Line Reference.


Table 5-3 lists the options that perform the same or similar functions on both the HotSpot and JRockit JVMs but have different names.

Table 5-3 Different Name; Same or Similar Function

HotSpot JVM Option JRockit JVM Option Function

-verbose:gc

-Xverbose:gc

This option prints log information about the memory system.

-Xmn, -XX:NewSize, and -XX:MaxNewSize

-Xns

This option sets the size of the young generation.

-XX:+UseConcMarkSweepGC

-Xgc:singlecon

This option sets the garbage collector to use a concurrent strategy.

-XX:+UseParallelGC

-Xgc:parallel

This option sets the garbage collector to use a parallel strategy.


Table 5-4 lists options available only when using the Oracle JRockit JVM.

Table 5-4 Options Available Only in the JRockit JVM

Option Function

-XpauseTarget

Specifies a suitable pause time for the application


Note:

-Xint and -XX:MaxPermSize, which are commonly used with the Hotspot JVM, are not valid for the JRockit JVM because the JRockit JVM has neither an interpreter nor a permgen space.