PHP、shell 命令和 jar 文件

发布于 2024-08-10 20:22:17 字数 198 浏览 2 评论 0原文

我有一个 jar 文件,我想使用 PHP 执行,但是当我运行脚本时,我得到的只是以下错误:无法为对象堆保留足够的空间。我做了一些搜索,似乎我得到了这个,因为该命令没有在登录 shell 中执行。如果是这种情况我该怎么办?我尝试了 shell_exec()exec() ,但都产生了相同的错误。

感谢您的帮助!

I have a jar file that I would like to execute using PHP, but when I run the script all I get is the following error: Could not reserve enough space for object heap. I have done some searching and it seems as though I am getting this because the command isn't being executed in a login shell. If this is the case how do I do so? I have tried both shell_exec() and exec() and both produce the same error.

Thanks for the help!

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

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

发布评论

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

评论(1

月朦胧 2024-08-17 20:22:17

使用 exec() 通常可以正常工作;但是,在您的情况下,Java 似乎无法分配足够的内存来启动(因此出现错误消息)。如果您在 RAM 有限且没有交换空间的虚拟机中运行,您会发现即使是最简单的 Java 程序也几乎不可能运行。

第一步是查看 java 是否在您的计算机上运行。尝试运行

java -version

如果失败并出现相同的错误,则必须以某种方式增加可用内存量(例如,购买具有更多内存或交换空间的计划)。如果不能,如果您使用 -Xmx16m 限制最大堆大小(将最大堆大小设置为 16 MB)甚至更小,您可能可以通过,但在这种情况下,您的 jar文件可能没有足够的内存来运行!

Using exec() would normally work properly; however, in your case it looks like Java is unable to allocate enough memory to start (hence the error message). If you're running in a virtual machine with limited RAM and no swap space, you'll find it all but impossible to run even the simplest java programs.

The first step is to see if java runs at all on your machine. Try to just run

java -version

If that fails with the same error, you'll have to increase the amount of memory available somehow (eg, buying a plan with more memory or swap space). If you can't, you might be able to get by if you limit the maximum heap size with -Xmx16m (sets the maximum heap size to 16 megabytes) or even less, but in that case your jar file may not have enough memory to run!

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