Show TOC

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

 

Developers programming applications to run on an SAP JVM can make use of the full Java 2 Platform SE 1.4 APIs 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 vendors' JDKs or other releases of SAP JVM.

End of the caution.

Procedure

The following sections deal with development-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 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 be running extremely slowly, 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, the jvmmon tool can be used.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 a separate tab.

After debugging mode is enabled, the SAP JVM will listen to the debugging port and wait for a debugger front end, 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 SAP JVM Profiler – can be easily integrated into NWDS or Eclipse by using the established plugin installation system of the Eclipse platform. The profiler plug-in 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 – Investigates the memory consumptions of your Java application and finds allocation hotspots

  • Performance Analysis – Investigates the runtime performance of your application and finds expensive Java methods

  • Method Parameter Trace – Yields detailed information about individual method calls including parameter values and invocation counts

  • Profiling Lifecycle Information – A lightweight monitoring trace for memory consumption, CPU load and GC events

  • Additional SAP AS Java Statistics – Shows information about users, session, requests and applications

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 1.4 Documentation Web site at http://download.oracle.com/javase/1.4.2/docs/api/index.html