DDE server using JNA?

82 views
Skip to first unread message

Jo D

unread,
Mar 5, 2021, 11:23:27 AM3/5/21
to Java Native Access
Hi all,

this is the first time we're dipping our toes into JNA waters, but at least we have a basic understanding of DDE, and even code that works (but that we can't/don't want to maintain and that we want to replace with JNA).

Question is: What do we need to do to run a DDE server(!) using JNA?
I did take a quick (but maybe incomplete) look at the examples directory, and searched the Internet for the combination of "dde" and "jna", and I found lots of DDE client code but not server.

Our existing code runs a single DDE server in its own thread, with a single topic, with the sole purpose of offering data that Excel worksheets can subscribe to.
I.e. it's a DDE server but a very simple one.

Any advice or pointers?

Thanks!
Jo

Jo D

unread,
Mar 5, 2021, 11:26:08 AM3/5/21
to Java Native Access
Sorry, I forgot a related question: The JNA DDE stuff is in a package that has "windows32" in its name.
Does that mean it won't run in a 64-bit application, or just that it accesses 32-bit APIs and accessing it from a 64-bit application is fine?

Regards,
Jo

Tres Finocchiaro

unread,
Mar 5, 2021, 1:09:59 PM3/5/21
to jna-...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/8b688574-e1e3-4fee-95b5-df0aadfcb765n%40googlegroups.com.

Matthias Bläsing

unread,
Mar 5, 2021, 3:20:01 PM3/5/21
to jna-...@googlegroups.com
Am Freitag, den 05.03.2021, 08:23 -0800 schrieb Jo D:
this is the first time we're dipping our toes into JNA waters, but at least we have a basic understanding of DDE, and even code that works (but that we can't/don't want to maintain and that we want to replace with JNA).

Question is: What do we need to do to run a DDE server(!) using JNA?

Nothing special - both client and server can be implemented with DDEML (Dynamic Data Exchange Management Library). DDEML is bound in jna-platform in mulitple abstraction levels.

I did take a quick (but maybe incomplete) look at the examples directory, and searched the Internet for the combination of "dde" and "jna", and I found lots of DDE client code but not server.

Our existing code runs a single DDE server in its own thread, with a single topic, with the sole purpose of offering data that Excel worksheets can subscribe to.
I.e. it's a DDE server but a very simple one.

Any advice or pointers?

jna-platform comes with bindings for the Ddeml library. Have a look at the unittest for the library:


The unittest are always client-server interactions, so every tested DDE interaction can be observed from the client and server perspective.

Sorry, I forgot a related question: The JNA DDE stuff is in a package that has "windows32" in its name.
Does that mean it won't run in a 64-bit application, or just that it accesses 32-bit APIs and accessing it from a 64-bit application is fine?

No - win32 is just the name used to identify the windows OS. With JNA you will only be able to call into libraries matching the architecture of the JVM that is running it. So with a 64Bit JVM you will only have access to 64bit libraries and the same holds true for 32bit accordingly.

At this time, I strongly suggest not to try to go down the 32bit route - more and more 32Bit JVMs are dying and you will riding a dead horse.

HTH

Matthias

Jo D

unread,
Mar 8, 2021, 4:27:56 AM3/8/21
to Java Native Access
Thanks for the pointer to the test code - I didn't notice it also contains server code, so that's a good starting point!

Our software currently is indeed delivered with Azul's 32-bit Java 11 JVM, and we don't have plans to switch that until Java 11 reaches end of life (which will take several years), so 32 bits is very much alive for us :-)
Doesn't mean we want to stick with that forever, of course, but there are always other priorities.

So... I take it that I can interface to DDEML functions using JNA, regardless of whether the JVM is 32 or 64 bits?
That would be very good news.

Would we have to change the JNA-facing code if/when we switch from 32 to 64 bits?

Regards,
Jo

Matthias Bläsing

unread,
Mar 8, 2021, 3:13:02 PM3/8/21
to jna-...@googlegroups.com
Hi,

Am Montag, den 08.03.2021, 01:27 -0800 schrieb Jo D:
> So... I take it that I can interface to DDEML functions using JNA,
> regardless of whether the JVM is 32 or 64 bits?
> That would be very good news.

To my experience microsoft is pretty good at providing 32bit and 64bit
binaries for the bundled libraries. Given, that DDE is old (old as in
10 years ago I would have considered it ancient) and that I tested it
on 64, I would expect it to work.

> Would we have to change the JNA-facing code if/when we switch from 32
> to 64 bits?

I would not expect that changes are required, but these are famous last
words, so I'd advice to have tests present, that check correct results.

Greetings

Matthias

Jo D

unread,
Mar 9, 2021, 2:47:08 AM3/9/21
to Java Native Access
Thanks, that's what I needed to know - I was worried that JNA platform might not provide 64-bit bindings, or that maybe MS wouldn't provide 64-bit functions in DDEML.
I didn't expect any of that, actually, but I wanted to make sure that there's none of those "oh but this approach could never have worked for <unexpected reason>" head-to-wall moments ahead.

Checking that it actually works - yeah, that's always the thing :-)
But since you report that 64 bits were successfully tested in the past, I am confident we can go that route as well, so that's very good news!

Thanks again!
Jo

Reply all
Reply to author
Forward
0 new messages