94

I am working on java wicket framework and Apache tomcat. When I tried to start tomcat, it shows Java Virtual Machine Launcher pop window "Could not create the Java Virtual Machine".

After clicking on "OK" button on Pop window, it shows the error on console.

Error occurred during initialization of VM.
Could not reserve enough space for object heap.

Please give me any reference or suggestions.

cottontail
  • 10,268
  • 18
  • 50
  • 51
Dnyani
  • 1,133
  • 3
  • 11
  • 15
  • 2
    What memory settings do you have for the launcher and how much actual memory do you have? – Jon Skeet Aug 27 '13 at 07:56
  • `Available Memory < Assigned memory for Launcher` – Narendra Pathai Aug 27 '13 at 07:59
  • 1
    I don't know if this will help or not, but there is a nifty utility named jvisualvm.exe that is packaged with the jdk. You should be able to find it in your jdk installation directory (i.e.-`C:\Program Files\Java\jdk1.7.0_17\jvisualvm.exe`). Using this graphical interface you can see the memory being allocated from the heap during startup. Let me know if you want more info and I'd be glad to provide it. – OnesAndZeros Aug 27 '13 at 19:33

15 Answers15

255

Error:

sony@sony-VPCEH25EN:~$ java --version
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Solution: Remove extra hyphen '-'

sony@sony-VPCEH25EN:~$ java -version
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
Community
  • 1
  • 1
KARTHIKEYAN.A
  • 18,210
  • 6
  • 124
  • 133
  • 67
    Damn it! (and thanks). Isn't that gravely inconsistent with nearly every other command line option? – Chris Oct 31 '17 at 03:04
12

I was also facing this issue when we upgraded from java 8 to java 10. I solved by removing

-Djava.endorsed.dirs="C:\Program Files\Apache Software Foundation\Tomcat 8.5\endorsed"

from the argument.

cottontail
  • 10,268
  • 18
  • 50
  • 51
  • 1
    Where is that "argument" thing? Is it in a file? – Gabriel Apr 28 '21 at 08:23
  • Agreed, generally the startup arguments are the problem. Try running your program with `java -jar program.jar` to see if it runs successfully, then try adding arguments. – Joehot200 Jul 03 '21 at 16:33
7
  • Press Windows+Pause keys simultaneously to open the "System" window. You can alternatively open the control panel manual to go there if you prefer it that way. Click on "Advanced system settings" on the left then click "Advanced" tab.
  • Select environmental variables here.
  • Click on new under System Variables.
  • Enter '_JAVA_OPTIONS' as the variable name.
  • Enter '-Xmx1024M' as the variable value.
  • Click ok twice.
Gabriel
  • 20,797
  • 27
  • 159
  • 293
Neelam Prajapati
  • 3,764
  • 3
  • 28
  • 62
  • I tried the solution you gave , first it closed my eclipse promptly then i edited "-Xmx1024M" instead of "-Xmx256M". Eclipse was now started but the exception persisted. I still get JVM could not start , fatal exception occurred , could you please suggest any other solution ? – Sahil Gupta Apr 22 '18 at 06:03
  • 1
    Life saver! Thanks, that was exactly what I needed. More people need to upvote. I didn't even know it was already set to `2048m` and setting it to `1024M` fixed my ESO installer problem. – ntrch Sep 07 '20 at 21:32
6

Edit your Catlina.bat so that your -Xmx settings are less than your physical memory

See Tomcat 7: How to set initial heap size correctly?

Community
  • 1
  • 1
Scary Wombat
  • 44,617
  • 6
  • 35
  • 64
2

Add the system variable _JAVA_OPTIONS and in the "new variable value" add "-Xmx1024M".

Xmx sets the maximum heap memory size

cottontail
  • 10,268
  • 18
  • 50
  • 51
2

I was facing the same issue while I was using "jdk-10.0.1_windows-x64_bin" and eclipse-jee-oxygen-3a-win32-x86_64 on Windows 64 bit Operating System.

I resolved this issue by changing my jdk to "jdk-8u172-windows-x64". Now it's working fine.

cottontail
  • 10,268
  • 18
  • 50
  • 51
1

The error does not say much and lot of things can be wrong. One thing that was wrong in my case was following

-x.DargName=108352123

Which is clearly wrong and should have been

-Dx.argName=108352123
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
procrazium
  • 21
  • 4
1

I was facing the same issue while I was using JDK 1.8.0_05 64 bit and eclipse-jee-oxygen-3a-win32-x86_64 on Windows 64 bit Operating System.

enter image description here

I resolved the issue by changing JDK version jdk1.8.0_05 to jdk1.8.0_172

cottontail
  • 10,268
  • 18
  • 50
  • 51
Prashant Sahoo
  • 979
  • 16
  • 19
1

For me it was picking the default JVM v6 set in env vars.

Needed to explicitly add below in eclipse.ini to use v8 which is req by photon.

-vm
C:\Program Files\Java\jdk1.8.0_75\bin\javaw.exe
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8

NOTE : Add the entry of vm above the vm args else it will not work!

Snehal Masne
  • 3,403
  • 3
  • 31
  • 51
1

You just need to add JAVA_HOME to your environment variable. Just point this variable to jdk location(not the jdk bin location) as shown in the below image.enter image description here

enter image description here

Rontu Barhoi
  • 55
  • 1
  • 7
0

If none of the other options works, then this could be an issue with the version of the JDK itself, just uninstall the current jdk and install the latest version.

I also faced this issue. After trying everything, I upgraded to the latest JDK and this issue was resolved on its own.

cottontail
  • 10,268
  • 18
  • 50
  • 51
Karthic.K
  • 416
  • 5
  • 15
0

I was facing the same issue when I was using tomcat 8.5 with Java 10. I installed Java 8(1.8.0_171) and it's working fine without any issues.

cottontail
  • 10,268
  • 18
  • 50
  • 51
RajieRoo
  • 121
  • 1
  • 9
0

On ubuntu (version 18), some application support java 8 and do not support java 11. If this is the case , you can switch to java 8 by following instruction on below topic : https://askubuntu.com/questions/1133216/downgrading-java-11-to-java-8

0

I had to add an older jdk on my project.

Right button on Project folder > Properties > Java Build Path > Libraries > Add Library > JRE System Library

enter image description here

enter image description here

In case you don't have the package for jdk8, download the jdk that some user mentioned above (http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-windows-x64.exe) and click on "Installed JREs" and search for the directory you downloaded the jdk8.

enter image description here

Then click on Finish.

Remove the apache server and add again.

The magic is done ;)

maryf
  • 140
  • 6
0

I had the same issue today when running the ancient software Dundjinni, a mapping tool, on Windows 10. (Dundjinni requires a rather old installation of Java; I haven’t tried updating Java, for fear the programme will fail.) My method was to simply run Dundjinni in administrator mode. Here is how:

Click Start or press the Start key, navigate down to the software, rightclick the programme, choose More, then choose Run as administrator. Note that this option is not available if you simply type the name of the software.

enter image description here

Canned Man
  • 734
  • 1
  • 7
  • 26