Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (Français) » MobiLink - Server Administration » MobiLink Server APIs » Writing synchronization scripts in Java » Writing Java synchronization logic

 

Debugging Java classes

MobiLink provides various information and facilities that you may find helpful when debugging your Java code. This section describes where you can find this information and how you can exploit these capabilities.

Information in the MobiLink server's log file

The MobiLink server writes messages to a message log file. The server log file contains the following information:

  • The Java Runtime Environment. You can use the -jrepath option to request a particular JRE when you start the MobiLink server. The default path is the path of the JRE installed with SQL Anywhere 11.

  • The path of the standard Java classes loaded. If you did not specify these explicitly, the MobiLink server automatically adds them to your classpath before invoking the Java virtual machine.

  • The fully specified names of the specific methods invoked. You can use this information to verify that the MobiLink server is invoking the correct methods.

  • Any output written in a Java method to java.lang.System.out or java.lang.System.err is redirected to the MobiLink server log file.

  • The mlsrv11 command line option -verbose can be used.

    See -v option.

Using a Java debugger

You can debug your Java classes using a standard Java debugger. Specify the necessary parameters using the -sl java option on the mlsrv11 command line.

See -sl java option.

Specifying a debugger causes the Java virtual machine to pause and wait for a connection from a Java debugger.

Printing information from Java

Alternatively, you may choose to add statements to your Java methods that print information to the MobiLink message log, using java.lang.System.err or java.lang.System.out. Doing so can help you track the progress and behavior of your classes.

Performance tip

Printing information in this manner is a useful monitoring tool, but is not recommended in a production scenario.

The same technique can be exploited to log arbitrary synchronization information or collect statistical information on how your scripts are used.

Writing your own test driver

You may want to write your own driver to exercise your Java classes. This approach can be helpful because it isolates the actions of your Java methods from the rest of the MobiLink system.