0
votes

I have an Azure Powershell Runbook which is used to invoke a java jar inside the Hybrid Worker Groups.

Currently we pass the absolute java path and run the program, Iwant to change this and pass JAVA_HOME instead. I have set java home as environment variable and is able to access inside the hybrid worker.

$java = $Env:JAVA_HOME
Write-Output "$java"

this give the right path when ran inside the hybrid.

When passing this value via runbook it is not returning any value. The Write-Output returns empty when running via Automation Runbooks

$java = $Env:JAVA_HOME
Write-Output "$Env:JAVA_HOME"
$arguments = "-cp C:\\prgm\jws\jar\jwsClient-0.0.1.jar"
$p = Start-Process -FilePath $java  -ArgumentList $arguments 

Any help is appreciated.

1

1 Answers

0
votes

Just a suggestion. Based on my experience, JAVA_HOME is usually used to store JDK path while in development. And to run a jar, we just need JRE.

But, I am not sure how Azure runbook sets its environment variables. You can output all environment variables as following:

Get-ChildItem env:* | sort-object name

If you know which variable stores the path of JRE, you may retrieve it with script then.