简体   繁体   English

如何允许桌面应用程序在同一台计算机上调用Java应用程序上的方法

[英]How to allow desktop applications to invoke methods on a Java application on the same machine

So I'd like to be able to allow other applications residing on the same machine to call into my Java application. 所以我希望能够允许驻留在同一台机器上的其他应用程序调用我的Java应用程序。

The call would either launch the app if not running and invoke the method or just invoke the method. 如果没有运行,调用将启动应用程序并调用该方法或只调用该方法。

Ideally the communication should be language independent as calling application could be written in any language. 理想情况下,通信应该与语言无关,因为调用应用程序可以用任何语言编写。

Has anyone done this before and can suggest things to explore/avoid? 有没有人以前这样做过,可以建议探索/避免的事情?

Thanks 谢谢

I'd use TCP and make your application into a daemon. 我使用TCP并将您的应用程序变成一个守护进程。 If you want your application to be easy for other platforms to integrate with, you should use a text based protocol that you define to suit your needs. 如果您希望您的应用程序易于与其他平台集成,则应使用您定义的基于文本的协议以满足您的需求。

And avoid XML if you don't need to transport complex structures. 如果您不需要传输复杂的结构,请避免使用XML。 (I'd go for JSON if you need more complex data transfer). (如果您需要更复杂的数据传输,我会选择JSON)。

If you are new to socket programming, this might help: 如果您不熟悉套接字编程,这可能会有所帮助:

http://download.oracle.com/javase/tutorial/networking/sockets/ http://download.oracle.com/javase/tutorial/networking/sockets/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM