简体   繁体   English

如何从jar文件创建Windows服务以及如何从另一个jar文件调用它?

[英]How to create windows service from jar file and how to call it from another jar file?

I have a jar file(primary jar) built for specific purpose. 我有一个用于特定目的的jar文件(主jar)。 It gets data as input and stores output as certain format files. 它获取数据作为输入,并将输出存储为某些格式的文件。 I have a another java app (secondary jar)built for secondary analysis with a user interface. 我有另一个Java应用程序(辅助jar),用于使用用户界面进行辅助分析。 Secondary jar uses primary jar for certain analysis. 次要jar使用主要jar进行某些分析。

Currently: The primary jar is initiated when secondary jar is started and stopped when secondary jar is closed. 当前:主jar在启动辅助jar时启动,而在辅助jar关闭时停止。 But i want to create primary jar as a service,so that it runs all the time and secondary jar just submits jobs to the primary jar service. 但是我想将主jar创建为服务,以便它一直运行,并且辅助jar只是将作业提交到主jar服务。

Issue: I have searched and found ways to wrap jar file into windows services. 问题:我已经搜索并找到了将jar文件包装到Windows服务中的方法。 But how to communicate with a running service from secondary jar app,sending data to it? 但是,如何通过辅助jar应用程序与正在运行的服务进行通信,并向其发送数据呢?

There are few ways to communicate between java processes: 在Java进程之间进行通信的方法很少:

  • old style RMI 旧式RMI
  • Socket 插座
  • shared file 共享文件
  • shared db 共享数据库

There are many ways, but you have to choose the one that is most appropriate for your problem. 有很多方法,但是您必须选择最适合您的问题的方法。

您可以使用JavaExe:它自动管理这两个过程(服务部分和用户界面部分)及其通信

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

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