0

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.

1 Answer 1

1

You have a typo; It should be:

String a;
a = br.readLine()
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks but that's not the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.