Calling Java from other programs

Discussion in 'Java' started by fsumathguy, Mar 3, 2008.

  1. fsumathguy

    fsumathguy Guest

    Hello. I am sure this has been asked numerous times before, but I am
    unable to find a conclusive answer. Please forgive me if this info is
    available elsewhere.

    I am developing a model to be used by others within my company.
    Because the end users are sort of a mixed bag with respect to
    technical backgrounds, we generally present everything in MS Excel.
    While Excel comes with VBA, I find this language cumbersome and
    annoying to develop anything larger than a few lines. My program of
    choice is Java. My question is, how can I do my development in Java,
    then compile the results into an executable that I could subsequently
    call from VBA? My boss (who is somewhat old school with repect to
    programming) does a similar thing using Fortran 90. He is able to
    generate a DLL file which allows him to pass all of the needed
    parameters to his Fortran routine from VBA. Can I do something
    similar with Java?

    Thanks in advance for any help.
    fsumathguy, Mar 3, 2008
    #1
    1. Advertising

  2. fsumathguy

    Arne Vajhøj Guest

    fsumathguy wrote:
    > I am developing a model to be used by others within my company.
    > Because the end users are sort of a mixed bag with respect to
    > technical backgrounds, we generally present everything in MS Excel.
    > While Excel comes with VBA, I find this language cumbersome and
    > annoying to develop anything larger than a few lines. My program of
    > choice is Java. My question is, how can I do my development in Java,
    > then compile the results into an executable that I could subsequently
    > call from VBA? My boss (who is somewhat old school with repect to
    > programming) does a similar thing using Fortran 90. He is able to
    > generate a DLL file which allows him to pass all of the needed
    > parameters to his Fortran routine from VBA. Can I do something
    > similar with Java?


    In theory you can:

    VBA---(Win32 DLL call)--->simple wrapper in C---(JNI call)--->Java

    In most cases I think it would be too cumbersome.

    Arne
    Arne Vajhøj, Mar 3, 2008
    #2
    1. Advertising

  3. fsumathguy

    Guest

    On Mar 3, 5:00 pm, Arne Vajhøj <> wrote:
    > fsumathguy wrote:
    > > I am developing a model to be used by others within my company.
    > > Because the end users are sort of a mixed bag with respect to
    > > technical backgrounds, we generally present everything in MS Excel.
    > > While Excel comes with VBA, I find this language cumbersome and
    > > annoying to develop anything larger than a few lines. My program of
    > > choice is Java. My question is, how can I do my development in Java,
    > > then compile the results into an executable that I could subsequently
    > > call from VBA? My boss (who is somewhat old school with repect to
    > > programming) does a similar thing using Fortran 90. He is able to
    > > generate a DLL file which allows him to pass all of the needed
    > > parameters to his Fortran routine from VBA. Can I do something
    > > similar with Java?

    >
    > In theory you can:
    >
    > VBA---(Win32 DLL call)--->simple wrapper in C---(JNI call)--->Java
    >
    > In most cases I think it would be too cumbersome.
    >
    > Arne


    Why not simply communicate with already running JVM.
    VBA <-> Java.

    It could be done by TCP/webservices/JNI/whatever.

    http://www.myjavaserver.com/~alexfromohio/
    , Mar 3, 2008
    #3
  4. fsumathguy

    Roedy Green Guest

    On Mon, 3 Mar 2008 07:16:52 -0800 (PST), fsumathguy
    <> wrote, quoted or indirectly quoted someone who
    said :

    >My program of
    >choice is Java. My question is, how can I do my development in Java,
    >then compile the results into an executable that I could subsequently
    >call from VBA?


    there are several approaches depending on how tight you need the
    coupling. Here are a few techniques.

    1. talk via an SQL database.

    2. communication via TCP/IP sockets. Each runs in its own address
    space.

    3. C++ exec java.exe

    4. C++ exec Jet compiled java. See
    http://mindprod.com/jgloss/jet.html/

    5. JNI where C++ spawns a JVM and calls Java methods.
    see http://mindprod.com/jgloss/jni.html

    for even more, see http://mindprod.com/jgloss/remotefileaccess.html
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Mar 3, 2008
    #4
  5. fsumathguy

    Arne Vajhøj Guest

    Roedy Green wrote:
    > 1. talk via an SQL database.
    >
    > 2. communication via TCP/IP sockets. Each runs in its own address
    > space.
    >
    > 3. C++ exec java.exe
    >
    > 4. C++ exec Jet compiled java. See
    > http://mindprod.com/jgloss/jet.html/
    >
    > 5. JNI where C++ spawns a JVM and calls Java methods.
    > see http://mindprod.com/jgloss/jni.html


    You do not need to spawn to call Java from C++.

    Arne
    Arne Vajhøj, Mar 4, 2008
    #5
  6. fsumathguy

    Arne Vajhøj Guest

    wrote:
    > On Mar 3, 5:00 pm, Arne Vajhøj <> wrote:
    >> fsumathguy wrote:
    >>> I am developing a model to be used by others within my company.
    >>> Because the end users are sort of a mixed bag with respect to
    >>> technical backgrounds, we generally present everything in MS Excel.
    >>> While Excel comes with VBA, I find this language cumbersome and
    >>> annoying to develop anything larger than a few lines. My program of
    >>> choice is Java. My question is, how can I do my development in Java,
    >>> then compile the results into an executable that I could subsequently
    >>> call from VBA? My boss (who is somewhat old school with repect to
    >>> programming) does a similar thing using Fortran 90. He is able to
    >>> generate a DLL file which allows him to pass all of the needed
    >>> parameters to his Fortran routine from VBA. Can I do something
    >>> similar with Java?

    >> In theory you can:
    >>
    >> VBA---(Win32 DLL call)--->simple wrapper in C---(JNI call)--->Java
    >>
    >> In most cases I think it would be too cumbersome.

    >
    > Why not simply communicate with already running JVM.
    > VBA <-> Java.


    Because that was not what was asked for.

    > It could be done by TCP/webservices/JNI/whatever.


    Is it possible to connect to a running JVM via JNI ??

    Arne
    Arne Vajhøj, Mar 4, 2008
    #6
  7. fsumathguy

    Roedy Green Guest

    On Mon, 03 Mar 2008 21:18:03 -0500, Arne Vajhøj <>
    wrote, quoted or indirectly quoted someone who said :

    >You do not need to spawn to call Java from C++.


    Not an exec call, but JNI does launch a JVM.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Mar 4, 2008
    #7
  8. fsumathguy

    Arne Vajhøj Guest

    Roedy Green wrote:
    > On Mon, 03 Mar 2008 21:18:03 -0500, Arne Vajhøj <>
    > wrote, quoted or indirectly quoted someone who said :
    >> You do not need to spawn to call Java from C++.

    >
    > Not an exec call, but JNI does launch a JVM.


    Yes. But it does not spawn.

    http://en.wikipedia.org/wiki/Spawn_(computing)

    Arne
    Arne Vajhøj, Mar 5, 2008
    #8
  9. fsumathguy

    Hugo Guest

    On Mar 3, 7:16 am, fsumathguy <> wrote:
    > Hello. I am sure this has been asked numerous times before, but I am
    > unable to find a conclusive answer. Please forgive me if this info is
    > available elsewhere.
    >
    > I am developing a model to be used by others within my company.
    > Because the end users are sort of a mixed bag with respect to
    > technical backgrounds, we generally present everything in MS Excel.
    > While Excel comes with VBA, I find this language cumbersome and
    > annoying to develop anything larger than a few lines. My program of
    > choice is Java. My question is, how can I do my development in Java,
    > then compile the results into an executable that I could subsequently
    > call from VBA? My boss (who is somewhat old school with repect to
    > programming) does a similar thing using Fortran 90. He is able to
    > generate a DLL file which allows him to pass all of the needed
    > parameters to his Fortran routine from VBA. Can I do something
    > similar with Java?
    >
    > Thanks in advance for any help.


    Direct calls can be pretty cumbersome.

    Can you use wire protocols such as XML-RPC or SOAP? This could be much
    more convenient; the wire protrocol calls can be used to initiate a
    request and the call handles within the VB or Java system.
    Hugo, Mar 6, 2008
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    12
    Views:
    1,635
    Dave Thompson
    Jan 10, 2005
  2. Dagorlas
    Replies:
    7
    Views:
    375
    Dagorlas
    Jun 16, 2006
  3. adeelmahmood
    Replies:
    11
    Views:
    910
    Alex Hunsley
    Feb 15, 2007
  4. Coca
    Replies:
    7
    Views:
    735
    Aidan Grey
    Aug 24, 2004
  5. Replies:
    18
    Views:
    618
    Dave Thompson
    Jan 10, 2005
Loading...

Share This Page