How does a native calling application get a return value from JNLP?
Asked Answered
C

4

6

I am launching a JNLP java application from a native client app (i.e. not a browser). When the JNLP finishes it's task, I need it to return a string to the calling app? 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?

Cryogen answered 12/10, 2016 at 8:8 Comment(2)
Please, can you post an example of how are you doing the call?Christianechristiania
@karelss - javaws <jnlp file> is called by Process::Start in C#Cryogen
C
2

Answering my own question!

I write to stdout from the child process (the JNLP)

  • The parent launches the child process

    Process::Start
    
  • Read stdout from Parent

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

Anyone sees any problem in this?

Cryogen answered 21/10, 2016 at 9:21 Comment(0)
B
1

If the all-permissions element is specified, you could try to set an environment variable which you can read from your C# application.

Set environment variable in Java:

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

Read environment variable in C#:

ProcessStartInfo p = new ProcessStartInfo("start ....");
....
string returnValue = p.EnvironmentVariables["returnValue"];
Biliary answered 20/10, 2016 at 16:36 Comment(1)
Don't think this will work - child is a separate process - it inherits a copy of the env variables of the parent - any changes in the variable values in the child will not be reflected in the parent - at least this is how it works on most operating systems - will test it on windows and see.Cryogen
S
1

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. 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?

Spur answered 20/10, 2016 at 16:37 Comment(0)
C
1

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

Christianechristiania answered 20/10, 2016 at 16:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.