Show TOC

Procedure documentationDeveloping on SAP JVM Locate this document in the navigation structure

 

Procedure

Developers programming applications to run on an SAP JVM can make use of the full Java 2 Platform SE 5APIs as described in the specification.

Caution Caution

It is strongly advisable not to use any classes from the packages com.sap.* or com.sun.* directly in applications, as these packages contain implementation specific classes that are subject to change or removal at any time. Java code using these classes may not be compatible with other vendor’s JDKs or other releases of the SAP JVM.

End of the caution.

The following sections deal with debelopment-related tasks, which are supported by SAP features and tools.

Debugging

Debugging Java code on an SAP JVM is very easy with an Eclipse based development environment like the SAP NetWeaver Developer Studio (NWDS). This description refers to this scenario. As the SAP JVM understands the standard Java Debug Wire Protocol (JDWP), any front-end for Java debugging should work with the SAP JVM without extra configuration work.

Stand-alone Debugging

The most basic way of debugging standalone applications is starting the application in NWDS or Eclipse using a debug configuration that selects the SAP JVM as runtime JRE. The familiar debugging procedures work as expected with any JDK or JRE.

Note Note

Performance hint: If the application seems to run extremely slow, make sure that no method entry or method exit breakpoints are in use, as they force the VM to run the application in interpreter mode. In addition they generate extra communication overhead between the VM and the debugger.

End of the note.
Remote Debugging

To debug an application on the SAP NetWeaver Application Server Java, the debugger can be attached remotely to the executing SAP JVM. The VM must be running in debugging mode, but due to the debugging-on-demand feature, this mode can be enabled at any time without further preparations.

To switch a running SAP JVM into debugging mode, any of the following tools can be used:

  • SAP Management Console (MMC)

    1. In the SAP Systems tree, select the AS Java Process Table node under the Java instance node.

    2. In the process table, find the server node of interest and select   All Tasks   Enable debugging   n its context menu. Debugging mode will be enabled for this server node.

    3. Check this in the Debug status column of the table; the debugging port used to connect a debugger is listed there, too.

  • Management Console in NWDS

    1. In the Management Console in NWDS (perspective SAP Management), select the Process Table sub-node under the AS Java node of the instance.

    2. In the process table, find the server node of interest and select Start Debug Session… in its context menu. Debugging mode will be enabled for this server node.

    3. Check this in the Debug column of the table; the debugging port used to connect a debugger is listed there in parentheses.

  • jvmmon

    The command-line tool jvmmon that is delivered as part of the SAP JVM can be used to switch a running SAP JVM to debugging mode by entering the command start debugging. The debugging port in use can be queried by entering the command print debugging information.

    A more comfortable way is using the GUI version of the jvmmon tool by starting jvmmon –gui. This presents a graphical interface to choose the VM instance and manipulate several settings, including the debugging mode. It also displays debugging information about the selected VM (including the debugging port) in an own tab.

After debugging mode is enabled, the SAP JVM will listen on the debugging port and wait for a debugger frontend, e.g. the NWDS or Eclipse, to connect.

To attach the NWDS or Eclipse debugger to the waiting VM, create a new Debug Configuration using the standard (and pre-selected) connection type Socket Attach and filling in the correct host and the debugging port of the waiting VM. When debugging is started, the VM will resume running under the control of the debugger.

To finish debugging, choose Disconnect to detach the debugger from the VM and disable debugging mode again.

Profiling

Profiling Java code with the SAP JVM works very much along the lines of debugging. The VM must be switched to debugging mode and the profiler front-end attaches to the VM using the debugging port. The user interface – the so-called SAP JVM Profiler – can be easily integrated into NWDS or Eclipse by using the established plugin installation system of the Eclipse platform. The profiler plugin provides a new perspective similar to the debugging perspective.

In addition to the common debugging operations, several profiling traces can be enabled or disabled at any point in time, resulting in snapshots of profiling information for the exact points of interest. The SAP JVM Profiler helps with the analysis of this information and provides views of the collected data with comprehensive filtering and navigation facilities.

The offered profiling traces address the following use cases:

  • Memory Allocation Analysis – Investigate the memory consumptions of your Java application and find allocation hotspots

  • Performance Analysis – Investigate the runtime performance of your application and find expensive Java methods.

Extensive information about the SAP JVM Profiler, its installation and features can be found here: https://www.sdn.sap.com/irj/scn/wiki?path=/display/Java/Java+Profiling. This site also offers tutorials for getting started, documentation about some advanced topics and tips and tricks for efficient usage of the Profiler GUI.

More Information

Tracing facilities

Tools and Commands

Handling SAP JVM problems

API and Language Documentation

The Java Language Specification can be read online and downloaded from http://java.sun.com/docs/books/jls/index.html. For API documentation please refer to the JDK 5 Documentation website at http://java.sun.com/j2se/1.5.0/docs/