如果您的计算机上正确安装了Java ,那么运行基于(Java)Java的应用程序或游戏应该不会有任何问题。
但是,如果您的设置有问题,您可能会看到错误消息“无法创建Java虚拟机。(Machine.)” 此错误意味着您计算机上的Java安装无法启动通常会在其中启动Java应用程序的虚拟沙箱(虚拟机)。
在本指南中,您将了解一些可以消除此错误的修复程序,从最常见的修复程序开始,对不太可能的解决方案进行修复。
确保(Make)Java安装(Java Is Installed)正确
在解决任何Java错误之前,您需要确保已正确安装Java。
为此,请通过选择“开始(Start)”菜单、键入cmd并选择“命令提示符(Command Prompt)”应用程序来打开命令提示符。
在命令提示符窗口中,键入java -version并按Enter。
如果Java安装正确,您应该会看到Java版本、SE 运行时环境(SE Runtime Environment)和客户端 VM(Client VM)构建。
如果您没有最新版本,则需要确保安装它(install it)。如果这看起来不错,您就可以继续进行下一个故障排除步骤了。
扩展(Expand Available System Memory)Java的可用系统内存
“无法(Could)创建Java虚拟机”错误的最常见原因是您的系统上的Java没有足够的可用内存来启动 VM 客户端。
Java最初默认设置为使用初始和最大“堆大小”。因此,如果您正在运行任何超出最大大小的应用程序,则会触发错误。
您可以通过更改Java(Java)可以在您的系统上使用 的系统内存量来调整它。
1. 选择开始(Start)菜单并输入环境变量。选择编辑系统环境变量(Edit the System Environment Variables)。
2. 在系统属性(System Properties)窗口中,选择环境变量(Environment Variables)。
3. 在系统变量(System Variables)窗格下,选择新建(New)。
4. 将变量名称设置为_JAVA_OPTIONS并将变量值设置为-Xmx512M。
5. 选择确定(OK),然后再次选择确定(OK)。
这会将Java(Java)的允许内存调整为512 Mb。设置更改会立即生效,因此请重新启动您的Java应用程序并查看错误是否仍然出现。如果是这样,请重复上述过程,但通过将值设置为-Xmx1024M来将内存增加到 1024 Mb 。
以管理员身份运行 Java
有时虚拟机错误可能是由于您的 Windows PC 上缺乏适当的管理员权限而导致的。要查看这是否是问题所在,请将PC 上的Java应用程序设置(Java)为以系统管理员身份运行(run as the system administrator)。
1. 选择开始(Start)按钮并输入Java。选择它旁边的右箭头,然后选择Open file location。
2. 右键单击 Java可执行文件并选择属性(Properties)。
3. 选择兼容性(Compatibility)选项卡并启用以管理员身份运行程序(Run the program as an administrator)复选框。
选择确定(OK)。现在,下次运行Java时,它将拥有完全的管理员权限。
卸载并重新安装 Java
最后,如果一切都失败了,您可能只是安装了错误的Java。
1. 选择开始菜单,输入添加或删除程序(add or remove programs),然后选择添加或删除程序(Add or remove programs)系统设置。
2. 在Apps & Features中,向下滚动到Java,选择它,然后选择Uninstall。
3. 选择是(Yes)确认,一旦Java完全卸载(Java is fully uninstalled),重新启动Windows。
4.为您的系统下载最新版本的 Java(Download the latest version of Java)。如果您的系统是 32 位,请确保选择 32 位;如果您的 PC 是 64 位,请确保选择 64 位。如果您不确定您拥有的是哪个系统,请务必先检查您的系统类型(check your system type first)。
5. 下载后双击安装文件。选择安装(Install)按钮以启动Java安装过程。
完成向导的其余部分,一旦Java安装完成,重新启动您的Windows系统。
清除“无法创建Java 虚拟机(Java Virtual Machine)”
希望您可以在前几个步骤中清除错误,而不必重新安装Java。但是,重新安装Java是一个足够快的过程,应该可以让您的Java应用程序再次顺利运行。
您是否发现任何其他修复也适用于此错误?在下面的评论部分与我们分享!(Share)
How to Fix “Could Not Create the Java Virtual Machine” Error
If Java is installed сorrеctly on your computer, you should never haνе any problem running Java-bаsed applications or games.
However, if there’s something wrong with your setup, you may see the error, “Could not create the Java Virtual Machine.” This error means that the Java installation on your computer can’t launch the virtual sandbox (virtual machine) within which it would typically launch the Java app.
In this guide, you’ll learn a few fixes that can eliminate this error, starting with the most common fix to the less likely solution.
Make Sure Java Is Installed Correctly
Before you can troubleshoot any Java errors, you’ll need to ensure that you’ve installed Java correctly.
To do this, open the command prompt by selecting the Start menu, typing cmd, and selecting the Command Prompt app.
In the command prompt window, type java – version and press Enter.
If Java is installed correctly, you should see the version of Java, the SE Runtime Environment, and the Client VM build.
If you don’t have the latest version, you’ll want to make sure to install it. If this looks good, you’re ready to move on to the next troubleshooting step.
Expand Available System Memory for Java
The most common cause for the “Could not create the Java Virtual Machine” error is that Java doesn’t have enough available memory on your system to launch the VM client.
Java is initially set by default to use an initial and maximum “heap size.” So, if you’re running any application that goes beyond the maximum size, it will trigger an error.
You can adjust this by changing the amount of system memory Java can use on your system.
1. Select the Start menu and type environmental variables. Select Edit the System Environment Variables.
2. In the System Properties window, select Environment Variables.
3. Under the System Variables pane, select New.
4. Set the Variable name as _JAVA_OPTIONS and set the Variable value as -Xmx512M.
5. Select OK, and then select OK again.
This adjusts the allowable memory for Java to 512 Mb. The setting change takes effect immediately, so relaunch your Java app and see if the error still appears. If it does, repeat the process above but increase the memory to 1024 Mb by setting the value to -Xmx1024M instead.
Run Java As Administrator
Sometimes virtual machine errors can be caused by the lack of appropriate admin rights on your Windows PC. To see if this is the issue, set up the Java app on your PC to run as the system administrator.
1. Select the Start button and type Java. Select the right arrow next to it and select Open file location.
2. Right-click the Java executable file and select Properties.
3. Select the Compatibility tab and enable the Run the program as an administrator checkbox.
Select OK. Now, the next time Java runs, it will have full administrator rights.
Uninstall and Reinstall Java
Finally, if all else has failed, you may just have a faulty installation of Java.
1. Select the Start menu, type add or remove programs, and select Add or remove programs system settings.
2. In Apps & Features, scroll down to Java, select it, and select Uninstall.
3. Select Yes to confirm, and once Java is fully uninstalled, restart Windows.
4. Download the latest version of Java for your system. Make sure you choose 32 bit if your system is 32 bit or 64 bit if your PC is 64 bit. If you’re not sure which system you have, make sure to check your system type first.
5. Double click the installation file after downloading. Select the Install button to launch the Java installation process.
Walk through the rest of the wizard, and once the Java installation is complete, restart your Windows system.
Clearing Up “Could Not Create the Java Virtual Machine”
Hopefully, you could clear the error in the first few steps and didn’t have to reinstall Java. However, reinstalling Java is a quick enough process and should get your Java apps running smoothly again.
Were there any other fixes you discovered that also worked with this error? Share them with us in the comments section below!