I am trying to run a simple java file remotely from my machine using Powershell. Java files re requires user to enter argument at run time. Powershell successfully connects to the remote machine but fails at the line when code asks for argument. I have tried to run the code locall using Powershell and it runs successfully, my best guess is the problem has to do something this file being executed remotely.
Powershell script to connect to remot machine
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1000"}'
Enable-PSRemoting -Force
$username = "username"
$secpass = ConvertTo-SecureString "pass" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($username,$secpass)
Enter-PSSession -ComputerName remote_address -Credential $mycreds
Java line which fails:
String a;
a = br.readLine();
Powershell Error:
java.exe : Exception in thread "main" java.lang.NullPointerException
+ CategoryInfo : NotSpecified: (Exception in th...ointerException:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
at Test.main(Test.java:24)
PS: The java file runs successfully when I hard code the argument.Also, I can't use command line argument for this purpose which also runs without any error by the way.