Announcement

Collapse
No announcement yet.

Java call into PB-DLL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java call into PB-DLL

    Has anyone attempted, or is it even possible
    for a Java app to call into a PB-DLL?

    Our Java guys would like to build a web based
    interface and I have a great deal of my project
    in PB DLL's and would prefer not to let them
    touch any of my code which works so well.

    I thought one approach could be to make ip-port
    access available to their app. Then got to
    thinking (sometimes a bad idea , why couldn't
    a applet call into the dll directly?

    Any thoughts/suggestions?

    Thanks all,

    Michael Ritter


    ------------------

  • #2
    Yes, you can make calls to DLLs in Java via the Java Native Interface (JNI). Go to any search engine and look for JNI and DLL and Windows - you should find a lot of material to help you out.

    For example:
    http://community.borland.com/article...,20679,00.html http://mindprod.com/jni.html

    Most of the examples are in C/C++, but the idea is the same.

    There are other ways to do interop as well, like SOAP (http://www.develop.com/soap). In fact, if you're doing machine calls via the Internet, SOAP may be the way to go.

    Regards,

    Jason

    ------------------

    Comment


    • #3
      Thanks Jason,

      The Java Nuts here have successfully called into
      a C dll using JNI and the examples. The Next step
      is a little of a mystery to me. How do I provide
      access to my PB-DLL's? What I am wondering, javah.exe
      creates the prototypes for the C program
      and we also include jni.h in the C compile.
      Would I/Could I port these headers
      to let them access the PB-DLL directly or should
      I create a wrapper from a C prog to my functions in
      PB (yuck!). I am at a loss concerning the
      path I should wander, any suggestions?

      Cheers,

      Michael

      ------------------

      Comment


      • #4
        I would personally port the created C code over to PB/DLL. My guess is that this should be doable. I wouldn't want a Java-to-C-to-PB/DLL layering construct if I could avoid it.

        Of course, this may be an interesting third-party tool for someone to create - something akin to javah for PB so you wouldn't need to do the language translation. Any takers?

        Regards,

        Jason

        ------------------

        Comment


        • #5
          Michael;

          You might find the following interesting :

          Clearsand Corp. has a product called MediaForge which is a
          direct competitor to Macromedias Director. It sports a Basic
          scripting language as well. What makes the product interesting
          is that it has its own Web Browser plugin so you can deliver
          apps via the web. It allows you to do multimedia on the web.

          One of the clever features it has is that you can use DLLs as
          objects within your app. Those DLLs can be "embeded" within
          your web app as well. A project created with MediaForge can be
          compressed into a single file for use on the web and the DLL
          can be embeded into that file.

          I have been a long time Beta tester for MediaForge I wrote a
          code generation tool for creating PB DLLs for use with MediaForge
          (it comes with MediaForge). MediaForge "supports" the use of PB
          DLLs and even has template code for making PB DLLs that act like
          sprites within a MediaForge application. A PB DLL can even make
          calls back into the MediaForge runtime itself.

          Clearsand "supports" the use of PB DLLs with MediaForge because
          of my efforts and all of the PB code generation tools that ship
          with MediaForge were written by me.

          It is a great combination !

          The lead programmer at Clearsand was "amazed" at the size and speed
          of the DLLs I wrote with PB DLL !


          MediaForge was written in C++ and he was surprised that a Basic
          compiler could produce such fast and small DLLs.

          If you are looking for alternatives to Java for the Web that is
          "guaranteed" to work with PB DLLs, then MediaForge is worth
          looking at.

          http://www.clearsand.com




          ------------------
          Chris Boss
          Computer Workshop
          Developer of "EZGUI"
          http://cwsof.com
          http://twitter.com/EZGUIProGuy

          Comment


          • #6
            I agree with you Jason about wrapping the
            functions. Why create a useless layer of
            indirection? I for one would take on the
            challenge (javah for pb) but feel that
            I lack the skills with java to pull it
            off effectively. I would gladly assign
            some time to the project if someone else
            would lead it. I think it would be a useful
            addition to our pb aresenal. To know if it's
            a worthwhile venture, is anyone else
            interested in calling PB-DLL's from Java?

            Chris - I checked out MediaForge as suggested.
            I understand from their pages that it is geared
            towards multimedia. It could be interesting as you
            suggest. I will sign up for their demo to check
            it out, but I fear that our Java guys are not
            going to like the idea. I am also assuming that
            I would have to carry around a great deal of
            extra code geared towards Multimedia with
            MediaForge that I don't need (I know, the JVM
            is quite heavy too) but my uninitated
            take is that in the long run, we would have
            more flexibility with Java on top instead of
            MediaForge. Thanks for the idea, I will get the
            demo to work with so that I may get a better
            evaluation of the product.

            Cheers,

            Michael

            ------------------

            Comment


            • #7
              Hi Michael

              porting Javah (building support for calling PowerBASIC native
              methods from Java) would be quite a bit of work/slogging through
              the API documentation.

              A better alternative which also wouldn't weaken Java memory management
              etc would be to use sockets for communication between the Java app
              and your PB app.

              TCP communication is straightforward in both Java and PowerBASIC -
              it's also the most portable method of interprocess communication.

              This would be my recommendation.

              Cheers

              Florent

              ------------------

              Comment


              • #8
                Florent,

                That was one of my initial thoughts, thanks
                for confirming it's validity. Sockets do look
                like the easiest to implement but I had not
                considered the other factors that you mention.
                Thanks for your thoughts.

                Michael

                ------------------

                Comment

                Working...
                X