Click here to Skip to main content
15,885,537 members
Articles / Programming Languages / Java
Tip/Trick

Debug Java Code in Java COM Windows Application (Remote Java Debugging)

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
18 Oct 2013CPOL1 min read 9.4K   1  
Debugging Java JNI and C++ code in COM based application

Introduction

I recently got the chance to setup Java debug environment for Java-COM based Windows application. Here the VB6 code is used for showing the User interface of application while Java and C++ code includes business logic of the application. To fix some bugs in the application, a debug environment was required which allows users to debug Java and C++ JNI code.

Using the Code

To debug C++, I used Visual Studio attach to process method and for Java code remote Java debugging of Eclipse was used.

Here are the details of the process that I used to debug Java.

We need to implement the following two steps:

  1. Launch the application and tell the JVM that it will be debugged remotely
  2. Create debug configuration in Eclipse IDE to debug application remotely. (in our case, it is localhost)

Pass the following argument to JVM:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8998

The above code should be placed at the location where JVM is loaded in the code.
Here 8998 denotes the port and suspend=n will make sure that the debugging is suspended till the Java code hits in the application.

In the Eclipse IDE, we need to create a new debug configuration and enter the following details in Connection Properties:

  • Host - localhost
  • Port - 8998

Now, click on apply, then launch the application. Now click on Debug in Debug configuration after setting debug points in the Java code.

Points of Interest

Using the above steps, we can debug the C++ and Java code simultaneously. This helped to understand proper functions flow in application.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Software Engineer having hands-on experience with C, C++, C#, .NET, ASP.NET, SQL, Website designing technologies, Joomla CMS, Application development, COM, MFC, Installshield, Installscript project, Basic MSI

http://newapputil.blogspot.in/
http://nvivekgoyal.blogspot.in/

Comments and Discussions

 
-- There are no messages in this forum --