Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Java remotely using PowerShell

When I run PowerShell in a remote session (etsn {servername}), I sometimes can't seem to run Java processes, even the most simple:

[chi-queuing]: PS C:\temp> java -cp .\hello.jar Hello
Error occurred during initialization of VM
Could not reserve enough space for object heap

Hello.jar is an "Hello, world!" application that should just print "Hello" to standard output.

So, the question is, is there something special about running processes on the other side of a PowerShell session? Is there something special about how the Java VM works that might not allow treatment like this? The memory is allocated on the remote computer, right? Here is a readout on the physical memory available:

[chi-queuing]: PS C:\temp> $mem = Get-wmiobject -class Win32_OperatingSystem
[chi-queuing]: PS C:\temp> $mem.FreePhysicalMemory
1013000

But, when I remote desktop to the server and ask the OS how much free memory there is, it says 270 MB physical memory free. Let me know what you think!

like image 568
lmat - Reinstate Monica Avatar asked Jan 19 '11 22:01

lmat - Reinstate Monica


People also ask

How do I run remote commands in PowerShell?

Running Remote Commands. You can run commands on one or hundreds of computers with a single PowerShell command. Windows PowerShell supports remote computing by using various technologies, including WMI, RPC, and WS-Management. PowerShell Core supports WMI, WS-Management, and SSH remoting. RPC is no longer supported.

How do I run a PowerShell script from another computer?

Windows PowerShell Remoting Using the WS-Management protocol, Windows PowerShell remoting lets you run any Windows PowerShell command on one or more remote computers. You can establish persistent connections, start interactive sessions, and run scripts on remote computers.

What is Windows PowerShell remoting and how does it work?

Using the WS-Management protocol, Windows PowerShell remoting lets you run any Windows PowerShell command on one or more remote computers. You can establish persistent connections, start interactive sessions, and run scripts on remote computers.

How to download and install Java JRE using PowerShell?

How to Download and Install Java JRE Using PowerShell? The following PowerShell script automatically downloads the latest version of Java installer from the official website and installs it on a computer (you can download both online and offline installer). The install command suppress reboot request and disables automatic Java updates.


1 Answers

According to this: http://msdn.microsoft.com/en-us/library/aa384372(VS.85).aspx

MaxMemoryPerShellMB Specifies the maximum amount of memory allocated per shell, including the shell's child processes. The default is 150 MB.

Increase Max Memory Per Shell MB

winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1000"}' 
like image 82
mjolinor Avatar answered Nov 15 '22 23:11

mjolinor