使用 PowerShell 远程运行 Java

发布于 2024-10-13 15:41:28 字数 865 浏览 9 评论 0原文

当我在远程会话中运行 PowerShell 时 (etsn {servername}) ,有时我似乎无法运行 Java 进程,即使是最简单的进程:

[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 是一个“Hello, world!”应用程序应该只将“Hello”打印到标准输出

那么,问题是,在 PowerShell 会话的另一端运行进程有什么特别之处吗? Java VM 的工作方式有什么特殊之处可能不允许这样的处理吗?内存是在远程计算机上分配的,对吧?以下是可用物理内存的读数:

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

但是,当我远程桌面到服务器并询问操作系统有多少可用内存时,它说有 270 MB 可用物理内存。让我知道你的想法!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

金兰素衣 2024-10-20 15:41:28

据此:
http://msdn.microsoft.com/en-us/库/aa384372(VS.85).aspx

MaxMemoryPerShellMB
指定每个 shell 分配的最大内存量,包括 shell 的子进程。默认值为150 MB

增加每个 Shell 的最大内存 MB

winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1000"}' 

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"}' 
水水月牙 2024-10-20 15:41:28

我有一个不同的答案想和大家分享。我发现自己处于同样的情况,增加 Java.exe 的最小/最大内存或使用 winrm 并没有解决我的问题。

我比较了两台服务器:一台工作,一台不工作。

我使用了此链接 https://technet.microsoft .com/en-us/library/ff520073%28v=ws.10%29.aspx 检查运行 WINRS 和远程 powershell 所需的 Windows Management Foundation。

结果:两台服务器都运行 Windows Server 2008 R2。一台服务器运行 WMF 2.0,一台服务器运行 WMF 3.0。

令我惊讶的是,运行 2.0 的服务器可以工作,而运行 3.0 的服务器却不能!

我的解决方案:我将3.0 WMF升级到4.0!

I have a different answer to share with you guys. I found myself in the same situation and increasing memory min/max for Java.exe or using winrm did NOT solve my issue.

I compared two servers: one working and one not working.

I used this link https://technet.microsoft.com/en-us/library/ff520073%28v=ws.10%29.aspx to check my Windows Management Foundation wich is needed to run WINRS and also remote powershell.

the result: Both servers running Windows Server 2008 R2. One server running WMF 2.0, one running WMF 3.0.

To my surprise, the server running 2.0 was working and the one running 3.0 was NOT!

My solution: I upgraded the 3.0 WMF to 4.0!

隔岸观火 2024-10-20 15:41:28

仅供参考:我们遇到了相同的症状,并根据其他两个答案进行了无休止的调查。
我们的实际解决方案是将 jdk1.8.0_31 更改为 jdk1.8.0_51。

Just a fyi: we suffered the same symptoms, and had an endless investigation based on the other two answers.
The actual solution for us was changing jdk1.8.0_31 to jdk1.8.0_51.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文