My problem was a little different because there are two jre versions and one jdk installed and powershell was always picking up jre based java executable and failing with the message
C:\Program Files\Java\jre1.8.0_73 is not a valid JDK Java Home.
Although jdk was installed and JAVA_HOME variable was set and out of variable displays the jdk path correctly.
> $env:JAVA_HOME
C:\Program Files\Java\jdk1.8.0_73
I stored the jdk java executable path in a variable, navigated to the directory containing jar file for Web logic server and invoked the installation program using following code.
$java="C:\Program Files\Java\jdk1.8.0_73\bin\java"
Start-Process -FilePath $java -ArgumentList '-jar fmw_12.2.1.3.0_infrastructure_generic.jar'
The installation program opened after few seconds. I have omitted -RedirectStandardErro switch to keep the command small and simple although i did use it to catch any error in the first place.
I tried using variable $fmw to store the jar file fmw_12.2.1.3.0_infrastructure_generic.jar
but it did not work. Unsuccessful code is as follows
$fmw="fmw_12.2.1.3.0_infrastructure_generic.jar"
Start-Process -FilePath $java -ArgumentList '-jar $fmw'
I hope this would help someone and somebody might provide me a better and clean method to call jar files in powershell.