VB.Net + Java Access Bridge-VBForums
Results 1 to 10 of 10

Thread: VB.Net + Java Access Bridge

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    38

    Question VB.Net + Java Access Bridge

    Anyone familiar with it? http://docs.oracle.com/javase/access...0.2/index.html

    Allows you to view items, etc, similar to AutoIT, but specifically for SwingSet2 Java applications. It has the includes for C++ (if I'm understanding it correctly). I've seen very few sites with anyone posting any ACTUAL knowledge on how to use it with VB.net, just a few posts here and there about the subject.

    Any thoughts?

  2. #2
    Fanatic Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    549

    Re: VB.Net + Java Access Bridge

    Here is a sample I found:

    https://github.com/jdog3/JavaAccessBridge.Net-Sample

    Programming against that API does not look fun however . I guess its really just another API, but the examples I saw had a lot of platform invoke going on. Search for C# Related items instead of vb.net

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    38

    Re: VB.Net + Java Access Bridge

    yeah, that's the same one that I found... I've been sitting here at my cubicle at work, quite perplexed for about the last hour or so not even know where to begin. I have no idea how to even call the API. Like you, I found a lot of C# docs (which still seem rather lacking, but maybe it's just me).

    Eventually, i decided to say "Ah screw it... you taught yourself QBasic when you 8... How hard can C# be??" and installed the C# 2010 Express and grabbed a "Teach yourself in 24hrs" book.

    Thank god for coffee..............

  4. #4
    Fanatic Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    549

    Re: VB.Net + Java Access Bridge

    Quote Originally Posted by paradox34690 View Post
    yeah, that's the same one that I found... I've been sitting here at my cubicle at work, quite perplexed for about the last hour or so not even know where to begin. I have no idea how to even call the API. Like you, I found a lot of C# docs (which still seem rather lacking, but maybe it's just me).

    Eventually, i decided to say "Ah screw it... you taught yourself QBasic when you 8... How hard can C# be??" and installed the C# 2010 Express and grabbed a "Teach yourself in 24hrs" book.

    Thank god for coffee..............
    I take it you are required to automate a java app from VB.NET? The documentation on the API seems poor entirely.

    If you can write vb.net, you can pretty much write C#. That is one of the advantages to programming against the .NET API (the biggest thing that kills me is remembering the carriage return ";"!). There are multiple free converters available. You can take the code from those C# documents and convert it into VB.NET:

    http://www.developerfusion.com/tools...-to-vb/‎
    converter.telerik.com/‎
    http://www.carlosag.net/tools/codetranslator/

    Differences:
    http://www.harding.edu/fmccown/vbnet...omparison.html

    Dealing with unmanaged code calls:
    http://msdn.microsoft.com/en-us/library/ms973872.aspx

    If you are more comfortable with VB.NET, I would stick with it for better familiarity. I don't think a "Learn X Language in X Days" is going to help you with this task as the crux is more how to access and use the API than coding lists and classes in C#. But what do I know lol. As far as speculating, I assume there's more C# articles on that exact item since C# attracts the C++ guys, which is what the original documentation looked like it was in.

    Question is, what are you automating and why are you required to automate an existing app?
    Last edited by jayinthe813; Oct 31st, 2013 at 11:40 PM.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    38

    Re: VB.Net + Java Access Bridge

    See, that's the problem... I CAN write VB.net no issue. But I don't know how to incorporate this JAB API into what I'd code out.... I'd just really love to find someone that is like "Oh snap, here, this is how you initialze it into your vb... don't forget to setup the references to xxx" or whatever. I doubt this is going to happen however, so I'm just going to have to grunt down and learn it. It's okay tho, I've been meaning to for a year or two. It's just intimidating for me because I have no formal programming education. I'm self taught with everything and I put together some fairly impressive applications for my company. This is a whole new thing for me here with C# tho.

  6. #6
    Fanatic Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    549

    Re: VB.Net + Java Access Bridge

    Quote Originally Posted by paradox34690 View Post
    See, that's the problem... I CAN write VB.net no issue. But I don't know how to incorporate this JAB API into what I'd code out.... I'd just really love to find someone that is like "Oh snap, here, this is how you initialze it into your vb... don't forget to setup the references to xxx" or whatever. I doubt this is going to happen however, so I'm just going to have to grunt down and learn it. It's okay tho, I've been meaning to for a year or two. It's just intimidating for me because I have no formal programming education. I'm self taught with everything and I put together some fairly impressive applications for my company. This is a whole new thing for me here with C# tho.
    Code:
    Imports JabApiLib.JavaAccessBridge
    Imports System.Globalization
    Imports System.Threading
    
    Public Class JABDump
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim windowHandle As Integer
    
            If Integer.TryParse(txtWindowHandle.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, windowHandle) Then
                txtTreeOutput.Text = "Loading...."
                Application.DoEvents()
    
                Thread.Sleep(100)
    
                Dim vmID As Int32
                Dim javaTree As JabHelpers.AccessibleTreeItem = JabHelpers.GetComponentTree(windowHandle, vmID)
                txtTreeOutput.Text = vmID.ToString()
                txtTreeOutput.Text = txtTreeOutput.Text & JabHelpers.screenContentsString
    
            End If
    
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                    'Init the java access bridge.  This needs to be in the form load.
            JabApi.Windows_run()
        End Sub
    
    End Class
    Java Access Bridge is a technology that exposes the Java Accessibility API in a Microsoft Windows DLL, enabling Java applications and applets that implement the Java Accessibility API to be visible to assistive technologies on Microsoft Windows systems. Java Accessibility API is part of Java Accessibility Utilities, which is a set of utility classes that help assistive technologies provide access to GUI toolkits that implement the Java Accessibility API.
    This class should give you some hints that you need to reference the API (which is a dll file) by adding the reference just like any other reference you add in VB.NET. Then add it to the imports in your vb code.

    Apparently to initialize the bridge you add:

    Code:
            JabApi.Windows_run()
    to the form load event.....

    The point I am trying to get across is that learning C# better isn't a bad thing at all, but if you cant code the API commands in VB.NET, how do you expect them to code them in C#, it should be the same code? This means now you know C#, perhaps better, but you are as close to solving your problem then as now.
    Last edited by jayinthe813; Oct 31st, 2013 at 11:57 PM.

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    38

    Re: VB.Net + Java Access Bridge

    I realize that, and my original intention was to learn off of the same file that we're both looking at and carry forward as I always do. I've added API before for active directory, vlc, and a few other items and don't generally have issues with it. This one has given me a headache as I downloaded that zip file, and upon loading the .SLN file with VB, I get an error saying that that the .csproj file is "not supported by this version of the application". Would this have anything to do with me only have the VB 2010 Express version?

    As stated earlier, I now also have the C# 2010 Express IDE installed and as a test, i loaded the .SLN with C#... It says the same thing about the .vbproj file....

    Sounds like I need to get the non-express version to me. I'd think that having both IDE's installed currently and not being able to use the opposing IDE file with the other would also imply that me downloading the whole "Visual Studio 2010 Express" package would most likely result in the same thing. Would you agree?

    If that's the case, then once I have that, I *should* be able to move forward with this project.

  8. #8
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    87,252

    Re: VB.Net + Java Access Bridge

    There's not going to be any references because it's not .NET and it's not COM. It's Win32 so you're going to have to use it just like you would the Windows API. It's a C/C++ library that exports functions directly. You'll need to write .NET methods with signatures that correspond to the unmanaged signatures of the functions you want to call. You can then call those managed methods like you would any other. To map a managed method to an unmanaged function, you can use the Declare keyword in VB but the preferred approach in all .NET languages to to use the DllImport attribute. You may also need some other attributes to perform custom marshalling and you may also need to create managed equivalents of some unmanaged structures returned or taken as arguments by those functions.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    38

    Re: VB.Net + Java Access Bridge

    Semi Solution... Compile the .csproj portion (minus the .vbproj parts) as a DLL. You have to go into the build properties and enable the /UNSAFE switch. Open .vbproj file (minus the .csproj parts), add reference to .DLL file... Done. Now to experiment and learn me some more!

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    38

    Re: VB.Net + Java Access Bridge

    Quote Originally Posted by jayinthe813 View Post
    I take it you are required to automate a java app from VB.NET? The documentation on the API seems poor entirely.
    Ya know, i never answered this... I'm not looking to automate. I'm looking to monitor. Long story short, the Oracle team isn't helping with a data replication project I was wanting to do. The idea of the project all revolves around metrics analysis, so I said to myself "Wait, if I can monitor what my users are clicking on within this Javaw.exe based application, I attribute +1 (as well as other things) to that particular user.

    Quote Originally Posted by jayinthe813 View Post
    Question is, what are you automating and why are you required to automate an existing app?
    The "what" part is an Javaw.exe based application that is developed and maintained by our internal developers. I can't really discuss too much about it due to confidentiality. The "why" part is like I said... not really wanting to automate, but to monitor. Perhaps this JAB isn't the best way to go about to this????

    Seriously getting a headache....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.