Using Java Access Bridge from C# .Net

Hi,

This blog is to help automate Java Swing applications from .Net C# Application using Java Access Bridge (JAB).

Using Java Access Bridge from C#

Java Access Bridge is a downloadable component available from site https://java.sun.com/javase/technologies/accessibility/accessbridge/index.jsp. This gives a set of dlls which contains native code that communicates through JVM with Java Accessibility API on user interface objects of Java application. This way we can communicate to Java application.

This article will explain how to interact with Java Swing applications using the library distributed with JAB: WindowsAccessBridge.dll.

Operations automated on Java Swing Application

I have categorized the different actions that we can automate on a Java Swing application as following:

1. Get value from a particular User interface object.

a. Eg. Get value from a textbox, label etc.

2. Set value to a particular User interface object.

a. Eg. Set value to textbox, label etc.

3. Perform action on a particular User interface object.

a. Eg. Automate Click on Button

4. Handle events on firing of some action.

a. Eg. Automate action that should be taken on click of a button.

WindowsAccessBridge.dll includes functions using which we can perform all the operations.

To import the DLL function, and initialize Java Access use this code:

using System.Runtime.InteropServices;

public class JavaAPIFunc

    {

        [DllImport("windowsaccessbridge.dll", SetLastError = true)]

        internal extern static void Windows_run();

  public JavaAPIFunc ()

        {

            Windows_run();

  }

    }

 

The above code is the first step that is needed to use JAB from .net.I will soon blog on how each operations that I defined earlier can be achieved.

Thanks and Regards,

Rajee