Using OSSubProcess to invoke Java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using OSSubProcess to invoke Java

abergel
Hi!

On OS X, in a terminal, if I type: /usr/bin/java -version
I obtain:
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Using OSSubProcess, do-it-ing the following:

OSSUnixSubprocess new
   command: '/usr/bin/java';
   arguments: #('-version');
        environmentAt: 'JAVA_HOME' put: '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home';
        redirectStderr;
         redirectStdout;
   runAndWaitOnExitDo: [ :process :outString  |
       outString inspect
   ].

inspect an empty string.
Any idea what’s going on?

Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: Using OSSubProcess to invoke Java

bestlem
java -version outputs to stderr not stdout (also I don't think you need
JAVA_HOME /usr/bin/java will do what is needed)



On 20/06/2016 15:58, Alexandre Bergel wrote:

> On OS X, in a terminal, if I type: /usr/bin/java -version
> I obtain:
> java version "1.8.0_66"
> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
> Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
>
> Using OSSubProcess, do-it-ing the following:
>
> OSSUnixSubprocess new
>    command: '/usr/bin/java';
>    arguments: #('-version');
> environmentAt: 'JAVA_HOME' put: '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home';
> redirectStderr;
> redirectStdout;
>    runAndWaitOnExitDo: [ :process :outString  |
>        outString inspect
>    ].
>
> inspect an empty string.
> Any idea what’s going on?
>



--
Mark


Reply | Threaded
Open this post in threaded view
|

Re: Using OSSubProcess to invoke Java

abergel
Hi Mark,

This is what I thought. But it does not seem to work. I tried:

OSSUnixSubprocess new
  command: '/usr/bin/java';
  arguments: #('-version');
        redirectStderr;
         
  runAndWaitOnExitDo: [ :process :outString  |
      outString inspect
  ].

Or is it the redirectStderr that does not work properly?

Cheers,
Alexandre


> On Jun 20, 2016, at 11:42 AM, Mark Bestley <[hidden email]> wrote:
>
> java -version outputs to stderr not stdout (also I don't think you need JAVA_HOME /usr/bin/java will do what is needed)
>
>
>
> On 20/06/2016 15:58, Alexandre Bergel wrote:
>
>> On OS X, in a terminal, if I type: /usr/bin/java -version
>> I obtain:
>> java version "1.8.0_66"
>> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
>> Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
>>
>> Using OSSubProcess, do-it-ing the following:
>>
>> OSSUnixSubprocess new
>>   command: '/usr/bin/java';
>>   arguments: #('-version');
>> environmentAt: 'JAVA_HOME' put: '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home';
>> redirectStderr;
>> redirectStdout;
>>   runAndWaitOnExitDo: [ :process :outString  |
>>       outString inspect
>>   ].
>>
>> inspect an empty string.
>> Any idea what’s going on?
>>
>
>
>
> --
> Mark
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: Using OSSubProcess to invoke Java

Peter Uhnak
#runAndWaitOnExitDo: takes a cull-ed three-arg block with the process, stdout, and stderr; that way you can process stdout and stderr independently.

Try this

OSSUnixSubprocess new
  command: '/usr/bin/java';
arguments: #('-version');
redirectStderr;
runAndWaitOnExitDo: [ :process :out :err |
err inspect
].

Peter

On Mon, Jun 20, 2016 at 6:03 PM, Alexandre Bergel <[hidden email]> wrote:
Hi Mark,

This is what I thought. But it does not seem to work. I tried:

OSSUnixSubprocess new
  command: '/usr/bin/java';
  arguments: #('-version');
        redirectStderr;

  runAndWaitOnExitDo: [ :process :outString  |
      outString inspect
  ].

Or is it the redirectStderr that does not work properly?

Cheers,
Alexandre


> On Jun 20, 2016, at 11:42 AM, Mark Bestley <[hidden email]> wrote:
>
> java -version outputs to stderr not stdout (also I don't think you need JAVA_HOME /usr/bin/java will do what is needed)
>
>
>
> On 20/06/2016 15:58, Alexandre Bergel wrote:
>
>> On OS X, in a terminal, if I type: /usr/bin/java -version
>> I obtain:
>> java version "1.8.0_66"
>> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
>> Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
>>
>> Using OSSubProcess, do-it-ing the following:
>>
>> OSSUnixSubprocess new
>>   command: '/usr/bin/java';
>>   arguments: #('-version');
>>      environmentAt: 'JAVA_HOME' put: '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home';
>>      redirectStderr;
>>       redirectStdout;
>>   runAndWaitOnExitDo: [ :process :outString  |
>>       outString inspect
>>   ].
>>
>> inspect an empty string.
>> Any idea what’s going on?
>>
>
>
>
> --
> Mark
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.





Reply | Threaded
Open this post in threaded view
|

Re: Using OSSubProcess to invoke Java

Mariano Martinez Peck


On Mon, Jun 20, 2016 at 1:10 PM, Peter Uhnák <[hidden email]> wrote:
#runAndWaitOnExitDo: takes a cull-ed three-arg block with the process, stdout, and stderr; that way you can process stdout and stderr independently.


Exactly. 
 
Try this

OSSUnixSubprocess new
  command: '/usr/bin/java';
arguments: #('-version');
redirectStderr;
runAndWaitOnExitDo: [ :process :out :err |
err inspect
].


Indeed. This is what I think should work. And yes, I don't think the 'JAVA_HOME'  is needed. At least for this command.

Alex, let us know if Peter code worked.

Cheers, 
 

Peter

On Mon, Jun 20, 2016 at 6:03 PM, Alexandre Bergel <[hidden email]> wrote:
Hi Mark,

This is what I thought. But it does not seem to work. I tried:

OSSUnixSubprocess new
  command: '/usr/bin/java';
  arguments: #('-version');
        redirectStderr;

  runAndWaitOnExitDo: [ :process :outString  |
      outString inspect
  ].

Or is it the redirectStderr that does not work properly?

Cheers,
Alexandre


> On Jun 20, 2016, at 11:42 AM, Mark Bestley <[hidden email]> wrote:
>
> java -version outputs to stderr not stdout (also I don't think you need JAVA_HOME /usr/bin/java will do what is needed)
>
>
>
> On 20/06/2016 15:58, Alexandre Bergel wrote:
>
>> On OS X, in a terminal, if I type: /usr/bin/java -version
>> I obtain:
>> java version "1.8.0_66"
>> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
>> Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
>>
>> Using OSSubProcess, do-it-ing the following:
>>
>> OSSUnixSubprocess new
>>   command: '/usr/bin/java';
>>   arguments: #('-version');
>>      environmentAt: 'JAVA_HOME' put: '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home';
>>      redirectStderr;
>>       redirectStdout;
>>   runAndWaitOnExitDo: [ :process :outString  |
>>       outString inspect
>>   ].
>>
>> inspect an empty string.
>> Any idea what’s going on?
>>
>
>
>
> --
> Mark
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.








--
Reply | Threaded
Open this post in threaded view
|

Re: Using OSSubProcess to invoke Java

abergel
Yes it does! Thanks!!!

Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Jun 20, 2016, at 12:32 PM, Mariano Martinez Peck <[hidden email]> wrote:



On Mon, Jun 20, 2016 at 1:10 PM, Peter Uhnák <[hidden email]> wrote:
#runAndWaitOnExitDo: takes a cull-ed three-arg block with the process, stdout, and stderr; that way you can process stdout and stderr independently.


Exactly. 
 
Try this

OSSUnixSubprocess new
  command: '/usr/bin/java';
arguments: #('-version');
redirectStderr;
runAndWaitOnExitDo: [ :process :out :err |
err inspect
].


Indeed. This is what I think should work. And yes, I don't think the 'JAVA_HOME'  is needed. At least for this command.

Alex, let us know if Peter code worked.

Cheers, 
 

Peter

On Mon, Jun 20, 2016 at 6:03 PM, Alexandre Bergel <[hidden email]> wrote:
Hi Mark,

This is what I thought. But it does not seem to work. I tried:

OSSUnixSubprocess new
  command: '/usr/bin/java';
  arguments: #('-version');
        redirectStderr;

  runAndWaitOnExitDo: [ :process :outString  |
      outString inspect
  ].

Or is it the redirectStderr that does not work properly?

Cheers,
Alexandre


> On Jun 20, 2016, at 11:42 AM, Mark Bestley <[hidden email]> wrote:
>
> java -version outputs to stderr not stdout (also I don't think you need JAVA_HOME /usr/bin/java will do what is needed)
>
>
>
> On 20/06/2016 15:58, Alexandre Bergel wrote:
>
>> On OS X, in a terminal, if I type: /usr/bin/java -version
>> I obtain:
>> java version "1.8.0_66"
>> Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
>> Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
>>
>> Using OSSubProcess, do-it-ing the following:
>>
>> OSSUnixSubprocess new
>>   command: '/usr/bin/java';
>>   arguments: #('-version');
>>      environmentAt: 'JAVA_HOME' put: '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home';
>>      redirectStderr;
>>       redirectStdout;
>>   runAndWaitOnExitDo: [ :process :outString  |
>>       outString inspect
>>   ].
>>
>> inspect an empty string.
>> Any idea what’s going on?
>>
>
>
>
> --
> Mark
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.








--