tags:

views:

86

answers:

2

I have two programs I need to integrate. One is a Microsoft Access program. The other is a Java program. No flexibility on choice of platform for either one here, these are existing complex programs.

The Access program needs at some point to spit out one line of text which the Java program knows how to convert into a code (another line of text), and receive that code back. The Java program is simply a command line app, packaged as a jar, that takes in the one bit of text and spits out the other.

What is the simplest way to do this?

I take it Access can't do system calls directly because of security concerns, unless I'm missing something? Previously the conversion utility was packaged as a DLL and called through OLE. I can package the jar file as a DLL, but that seems roundabout. Is that the best I can do?

(If there is another similar question, just point me at it. In search results for Java and Access people tend usually to be doing the opposite: accessing an Access database through Java).

A: 

Why not simply spawn the Access process off as a subprocess of a Java program containing your existing .jar ? That way you don't have to perform any Java/MS-specific integration and you can make use of the existing .jar as a library in your new Java program.

Capture the stdout of the Access program, process it in Java and then write it back in via the stdin ? See the Process object for more info, and this answer for more info on how to consume stdout/err and links to an example.

Brian Agnew
Whoa, I guess I could do that... of course this forces the user to access the database via a Java program, and not directly from clicking the .mdb. I'll look into it though.
Erika
+1  A: 

How about using the technique described on this page.

You'd change the string that's given to the WScript.Shell.Exec() function to whatever command you need to execute your Java program. Then the Java program's output would be available via calling ReadAll() the Exec object's StdOut property.

schinazi