<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Rajee's Tech world</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/rajeen/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/rajeen/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:51:55 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Using Java Access Bridge from C# .Net</title>
      <link>https://docs.microsoft.com/archive/blogs/rajeen/using-java-access-bridge-from-c-net</link>
      <pubDate>Fri, 11 Jul 2008 02:34:00 GMT</pubDate>
      <dc:creator><![CDATA[Rajeen]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/rajeen/2008/07/11/using-java-access-bridge-from-c-net/</guid>
      <description><![CDATA[Hi,
This blog is to help automate Java&nbsp;Swing applications from .Net C# Application using Java...]]></description>
      <content:encoded><![CDATA[<P><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">This blog is to help automate Java&nbsp;Swing applications from .Net C# Application using Java Access Bridge (JAB).<o:p></o:p></SPAN></P>
<P><B style="mso-bidi-font-weight: normal"><U><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Using Java Access Bridge from C#<o:p></o:p></SPAN></U></B></P>
<P><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Java Access Bridge is a downloadable component available from site </SPAN><A href="https://java.sun.com/javase/technologies/accessibility/accessbridge/index.jsp"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"><FONT color=#0000ff>https://java.sun.com/javase/technologies/accessibility/accessbridge/index.jsp</FONT></SPAN></A><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">. 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&nbsp;communicate to Java application.<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'">This article will explain how to interact with Java Swing applications using the library distributed with JAB: WindowsAccessBridge.dll.<BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"><o:p></o:p></SPAN></P>
<P><B style="mso-bidi-font-weight: normal"><U><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Operations automated on Java Swing Application<o:p></o:p></SPAN></U></B></P>
<P><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">I have categorized the different actions that we can automate on a Java Swing application&nbsp;as following:<o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">1.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"><EM>Get value</EM>&nbsp;from&nbsp;a particular User interface object. <o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 1.25in; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">a.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Eg. Get value from a&nbsp;textbox, label etc.<o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">2.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"><EM>Set value</EM> to a particular User interface object. <o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 1.25in; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">a.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Eg. Set value to textbox, label etc. <o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">3.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"><EM>Perform action</EM> on a particular User interface object. <o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 1.25in; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">a.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Eg.&nbsp;Automate Click on Button <o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 0.75in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">4.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial"><EM>Handle events</EM> on firing of some action.<o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 1.25in; TEXT-INDENT: -0.25in; mso-list: l0 level2 lfo1"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana"><SPAN style="mso-list: Ignore">a.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: Arial">Eg. Automate action that should be taken on click of a button. <o:p></o:p></SPAN></P>
<P style="MARGIN-LEFT: 0.75in"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Arial','sans-serif'"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><I><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">WindowsAccessBridge.dll </SPAN></I><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">includes functions using which we can perform all the operations. <o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">To import the DLL function, and initialize Java Access use this code:<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes">using</SPAN><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"> System.Runtime.InteropServices;</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; BACKGROUND: silver; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes">public</SPAN><SPAN style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">JavaAPIFunc<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DllImport</SPAN>(<SPAN style="COLOR: #a31515">"windowsaccessbridge.dll"</SPAN>, SetLastError = <SPAN style="COLOR: blue">true</SPAN>)]<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">internal</SPAN> <SPAN style="COLOR: blue">extern</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: blue">void</SPAN> Windows_run();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>public</SPAN><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"> <SPAN style="COLOR: #2b91af">JavaAPIFunc</SPAN> ()<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Windows_run();<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; FONT-FAMILY: 'Courier New'; mso-highlight: silver; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-highlight: silver">}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-highlight: silver"></SPAN>&nbsp;</P><SPAN style="FONT-SIZE: 9pt; BACKGROUND: silver; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-highlight: silver"></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><o:p>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'">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.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'">Thanks and Regards,<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 10pt"><SPAN style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'">Rajee<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"></o:p></SPAN>&nbsp;</P>]]></content:encoded>
    </item>
  </channel>
</rss>