| Author |
Starting a process from a stream
|
Per Engstrom
Greenhorn
Joined: Feb 11, 2010
Posts: 9
|
|
Hi,
I'm looking into writing a license wrapper for a small utility application written in c++.
I want the java wrapper to both provide a nice GUI and enforce the license.
I imagine that the application will be encrypted and included in the jar-file.
A cipher to unchrypt it will be created by the wrapper based on conditions in the license (duration / executions whaterver...).
I want to do something like this:
(The first parameter to runtime.exec() on line 13 doesn't work.)
Thanks!
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
That's not going to happen, because the operating system doesn't allow it. I wish it could myself sometimes, but no.
What you can do is first extract the application to a temporary file, then execute that:
Some notes:
1) This will create a file like C:\Windows\Temp\app1213213.exe (on Windows), or possibly in the user's own temp folder. You can delete the file either when done (when p.waitFor() has returned) using app.delete(), or when the application has finished using app.deleteOnExit().
2) The entire command, including its arguments, goes into the first parameter. The second String[] argument is for environment variables, in the form name=value, e.g. "PATH=C:\Windows".
3) Read When Runtime.exec() won't.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Per Engstrom
Greenhorn
Joined: Feb 11, 2010
Posts: 9
|
|
Thanks for the info!
I feared that Java might not allow this, running in a sandbox and all...
Is there a way to ensure that the deciphered file is deleted on exit, and that it is not copied during execution?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
Nope. And it's not Java that doesn't allow this, it's the OS. You can't execute an executable program from the Internet either; you must first download it (possibly to a temp folder).
|
 |
 |
|
|
subject: Starting a process from a stream
|
|
|