How do I send commands to a running Java program?

I have a java program that I want to send commands from my Win32 Application Usually I use WM_ COPYDATA, but what options do I have for Java?

Solution

There are ways to interoperate between Java and windows Command power and difficulty:

>For processing window messages, you can use jawin – it even has demo of how to handle window messages or similar functions Of course, if you bind a java program to a library like jawin, it will never run on a non windows machine > for simple interaction between Win32 and Java, limiting the socket listening on localhost will be my favorite choice The protocol may be simple, but I prefer plain text protocol for debugging Please note that if the user terminates the program, the socket connection may be interrupted. > You can use (local) web services, as suggested in other posts here Both parties should ensure that the WebService / XML library is used to construct and parse messages. If you connect strings, it is too easy to construct malformed XML. > You can put the functions of windows programs into COM components and use java to com bridge: Jacob or j-interop is a popular free library, and j-integra seems to be a popular choice for enterprises with legacy systems. > You can put the functions of Java programs into COM components and use sun's Java ActiveX bridge According to my personal experience, this is a rather embarrassing choice: the development of Java ActiveX bridge has stagnated since 1.4. The installation of ActiveX makes it very troublesome to install Java components in a certain location in the JRE directory and debug Java components in the ActiveX container

Sidenote: if you want to handle strings on both sides, always consider Java treating strings as completely different from byte arrays Especially if you are using Windows ANSI strings, please note that characters 81, 8D, 8F, 90 and 9D are specified as undefined in the windows-1252 code page. Therefore, if the windows string contains these elements, Java will generate question marks or exceptions Therefore, if possible, use wchar strings on the windows side or limit your use of secure characters

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>