Debugging applications isn't usually an important consideration when you're deciding on application architectures or requirements. It's one of those items that becomes critical during development if you haven't planned ahead. With Java, iSeries developers usually have a good choice of debugging options. You can select the one that best fits your debug requirements. Debugging Java applications is a LARGE topic. This tip points out your options and some considerations for getting started.
Your options for debugging depend on the following:
- The type of Java application you want to debug
- The runtime environment for the Java application
- The available IBM tools you have for debugging
Development or deployment debugging requirement?
During the application development cycle I usually choose the VisualAge for Java IDE debugger, which is easy to use and offers complete application control. During deployment testing, I choose either the traditional iSeries command line debugger OR the new IBM Distributed Debugger.
Mapping Java application types to debug options
- VisualAge uses the built-in WebSphere Test Environment to run servlets and JSPs in the VisualAge IDE workspace so it can use the integrated debugger.
- A WebSphere servlet running on the iSeries can be debugged using the standard iSeries debugger, but it requires finding the WebSphere server job and running STRSRVJOB from a command line to attach to the running WebSphere job before selecting the thread and application to debug.
- Debugging ANY Java application usually requires having the correct Java version referenced for execution and the correct classpath set for all referenced classes, jars and zip files.
- Check the Java version your set up to run with:
java -- version
The displayed version number shows which Java runtime environment is loaded if there are multiple setup on your system.
Handling optimized Java classes
Debugging Java applications is different than with other types of applications. Java applications are USUALLY more effectively debugged when the Java application is composed of non-optimized class files. For iSeries, you have the option of using the Java transformer to optimize your Java classes which removes most debug information. You can choose to recompile the classes and specify a lower optimization level (00 or 10). For WebSphere Application Server, you choose the debug level for Java classes that are compiled (e.g., JSPs) by WebSphere at the application server level. You can set the debug level as an option during configuration on a specific application server instance.
iSeries standard debug support
This debugger is invoked from the 5250 command line. It allows setting breakpoints, stepping through an application and inspecting values in an application. It can be used to debug WebSphere classes and can use the STRSRVJOB capability from another job.
The iSeries debugger doesn't need to be installed, since it is a part of the platform for a given OS/400 version.
IBM VisualAge for Java integrated debugger
This debugger adds support for changing code dynamically and visually tracing JSP source execution. It is great during development.
The VisualAge debugger is automatically included with VisualAge in the IDE and doesn't require any setup (nice).
IBM Distributed Debugger
With the distributed debugger you also have the option to do the following:
- Load the application from the debugger to start
- Attach it to a running application on the local or remote system
To attach to an application on another system, a debug daemon has to be running on the server.
Configuring the debugger is NOT a simple task for a new developer. Don't get too frustrated.
The IBM Distributed Debugger is now included with all new releases of IBM Java development tools. It is an optional component that you have to separately install and configure.
What debug features do you need?
The features available depend on the debug tool you use. All the debuggers support step execution of Java code, setting variable watches to see values of variables. The Distributed Debugger also has built-in tracing support with graphical output that can be helpful.
The VisualAge debugger is integrated with the editor so you can change your code DURING debug and have the changes saved. That's a very productive feature during development.
The VisualAge debugger offers a JSP execution monitor that shows your JSP source running side by side with the generated Java servlet code. It's hard to debug generated WebShere servlets when the source is somewhat cryptic. This makes it easy to debug your JSPs.
Which is the easiest environment to debug with?
In my opinion, hands down it is the VisualAge for Java integrated debugger. It even works for servlets and JSPs when you run them in the WebSphere Test Environment.
Where possible, use the VisualAge debugger for development with VisualAge, WebSphere Studio or other IDEs. (You can import your Java code into VisualAge.)
Which is the best to debugger for applications running on the iSeries?
It depends on your skill sets. If you're an iSeries developer, running the existing iSeries debugger on Java classes makes sense. It's not too hard to do. If you're a Java developer with no real iSeries skills, try the Distributed Debugger. You may need some help with iSeries configuration parameters, but it should be easier to get started here.
What's the future of debugging Java applications?
For IBM, the Distributed Debugger will probably be the tool of choice. VisualAge will evolve into the new WebSphere Studio Application Developer over time, and its debugger will be changed in the new tool. The iSeries debugger is limited to the iSeries and can't work with remote applications such as the Distributed Debugger. Again, for developers new to the iSeries, the Distributed Debugger is probably a better investment. For experienced iSeries developers, the existing debug tool should be faster to use even though it is "green screen."
About the author: Jim is president of ebt-now.com, an IBM and Lotus business partner focused on delivering e-business application solutions for iSeries 400 customers. Jim writes, consults, teaches, designs and develops iSeries Web applications using Java, WebSphere, DB2, Lotus Domino and the WebSphere Development Tools for the iSeries.
- Building, deploying JSPs with WebSphere Studio: Get first-hand knowledge of how to use WebSphere Studio from site experts Jim Mason and Dave Slater. They give you tips for both designing JSP pages and debugging runtime errors in the WebSphere Test Environment.
.26RlaSVDeTg^1@.ee84637>WebSphere/Web development discussion forum:
Post your WebSphere and Web development questions here. You'll get advice from our site experts who monitor the forum, as well as ideas and suggestions from other users.
- Best Web Links on Web Development
This was first published in January 2002