简体   繁体   English

本机调用应用程序如何从JNLP获取返回值?

[英]How does a native calling application get a return value from JNLP?

I am launching a JNLP java application from a native client app (ie not a browser). 我从本机客户端应用程序(即不是浏览器)启动JNLP java应用程序。 When the JNLP finishes it's task, I need it to return a string to the calling app? 当JNLP完成它的任务时,我需要它将一个字符串返回到调用应用程序? How can I do this? 我怎样才能做到这一点? Is it possible to return a value to a calling app - or do I need to have the calling app listen on a port and have the JNLP app write the value to that port through sockets? 是否可以将值返回给调用应用程序 - 或者我是否需要让调用应用程序侦听端口并让JNLP应用程序通过套接字将值写入该端口?

Answering my own question! 回答我自己的问题!

I write to stdout from the child process (the JNLP) 我从子进程(JNLP)写到stdout

  • The parent launches the child process 父级启动子进程

     Process::Start 
  • Read stdout from Parent 从Parent中读取stdout

     string ret = process.StandardOutput.ReadToEnd(); 
  •  Process::WaitForExit(); 

Anyone sees any problem in this? 有人在这看到任何问题吗?

If the all-permissions element is specified, you could try to set an environment variable which you can read from your C# application. 如果指定了all-permissions元素,则可以尝试设置一个可以从C#应用程序中读取的环境变量。

Set environment variable in Java: 在Java中设置环境变量:

System.getenv().put("returnValue", "yourValue");

Read environment variable in C#: 在C#中读取环境变量:

ProcessStartInfo p = new ProcessStartInfo("start ....");
....
string returnValue = p.EnvironmentVariables["returnValue"];

I like your idea to use sockets and think this is could be an easy solution. 我喜欢你的想法使用套接字并认为这可能是一个简单的解决方案。

It is not possible to get return values from a WebStart-application. 无法从WebStart应用程序获取返回值。 Just see the help message from 只需查看来自的帮助消息即可

javaws --help

There is no return-code available. 没有返回代码。 (Sorry) (抱歉)

Have you thougth on a temporary file instead of the sockets? 你有没有在临时文件而不是套接字上?

It's a bit old but as fas as i know this is the exiting options to intercommunicate two process link . 它有点旧,但我知道这是两个进程链接相互通信的现有选择。

I think the easiest way to solve your problem is use rmi, or jmx if you can, or just a simple socket 我认为解决问题最简单的方法是使用rmi,或jmx(如果可以),或只是一个简单的套接字

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

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