title: Invalid initial heap size: -Xms128M -Xmx512M -Xss1024K -Dlog4j.debug ...?
body: <p>My setup:</p>
  
  <ul>
  <li>Windows 64 bits</li>
  <li>Java application loading 32 bits native modules</li>
  <li>Can be run fine outside the debugger using the 32bits Java (jdk1.6.0_29) with the following command line - "-Xms128M -Xmx512M -Xss1024K -Dlog4j.debug ..." (trimmed for brevity)</li>
  </ul>
  
  <p>The problem starts if I want to debug the native modules. So, I fire my windbg 64 bits using the following powershell command line:</p>
  
  <pre><code>windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;bu $entry;g;g" "$env:JAVA_HOME\bin\java.exe" $Params
  </code></pre>
  
  <p>Where <code>$Params</code> are exactly the same params used to run it outside the debugger.</p>
  
  <p>The debugger starts, but the sessions is very short:</p>
  
  <pre><code>Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64
  Copyright (c) Microsoft Corporation. All rights reserved.
  
  CommandLine: "c:\Program Files (x86)\Java\jdk1.6.0_29\bin\java.exe" "-Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper"
  Symbol search path is: C:\dev\shunra\DriverProxy\CloudAPI\CLOUDAPI\Profile\Stratus;C:\dev\shunra\DriverProxy\LocalDriverProxy\Profile;C:\dev\shunra\SharedModules\cJSON\lib\win32\Profile;C:\dev\shunra\SharedModules\curl\lib\win32\Profile;C:\dev\shunra\SharedModules\DataStruct\lib\win32\profile;C:\dev\shunra\SharedModules\GraphSetup\lib\win32\profile;C:\dev\shunra\SharedModules\multikey_lookup\lib\win32\profile;C:\dev\shunra\SharedModules\ShunraAPICommon\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraAPIEmulation\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraAPIParsers\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraAPIRest\lib\win32\Profile;C:\dev\shunra\SharedModules\ShunraUtils\lib\win32\profile;C:\dev\shunra\SharedModules\ShunraXercesUtils\lib\win32\profile;C:\dev\shunra\SharedModules\SNetXMLBuilder\lib\win32\profile;C:\dev\shunra\SharedModules\StormEngine\lib\win32\profile;C:\dev\shunra\SharedModules\xerces-c-2.80\Build\Win32\VC10\Profile;C:\dev\shunra\SharedModules\XMLControl\lib\win32\profile;srv*Z:\Symbols*http://msdl.microsoft.com/download/symbols
  Executable search path is: 
  ModLoad: 00000000`00400000 00000000`00424000   java.exe
  ModLoad: 00000000`77540000 00000000`776e9000   ntdll.dll
  ModLoad: 00000000`77720000 00000000`778a0000   ntdll32.dll
  ModLoad: 00000000`74da0000 00000000`74ddf000   C:\Windows\SYSTEM32\wow64.dll
  ModLoad: 00000000`74d40000 00000000`74d9c000   C:\Windows\SYSTEM32\wow64win.dll
  ModLoad: 00000000`74d30000 00000000`74d38000   C:\Windows\SYSTEM32\wow64cpu.dll
  (684.e30): Break instruction exception - code 80000003 (first chance)
  Processing initial command '!sw;bu LocalDriverProxy!Java_com_shunra_vcat_core_emulation_LocalDriverProxy_StartEmulation;g;g'
  ntdll!LdrpDoDebuggerBreak+0x30:
  00000000`775ecb60 cc              int     3
  0:000&gt; !sw;bu LocalDriverProxy!Java_com_shunra_vcat_core_emulation_LocalDriverProxy_StartEmulation;g;g
  Switched to 32bit mode
  ModLoad: 76e60000 76f7f000   WOW64_IMAGE_SECTION
  ModLoad: 00000000`75300000 00000000`75410000   WOW64_IMAGE_SECTION
  ModLoad: 00000000`76e60000 00000000`76f7f000   NOT_AN_IMAGE
  ModLoad: 00000000`77190000 00000000`7728a000   NOT_AN_IMAGE
  ModLoad: 00000000`75300000 00000000`75410000   C:\Windows\syswow64\kernel32.dll
  ModLoad: 00000000`752b0000 00000000`752f7000   C:\Windows\syswow64\KERNELBASE.dll
  ModLoad: 00000000`769a0000 00000000`76a40000   C:\Windows\syswow64\ADVAPI32.dll
  ModLoad: 00000000`76710000 00000000`767bc000   C:\Windows\syswow64\msvcrt.dll
  ModLoad: 00000000`76390000 00000000`763a9000   C:\Windows\SysWOW64\sechost.dll
  ModLoad: 00000000`75410000 00000000`75500000   C:\Windows\syswow64\RPCRT4.dll
  ModLoad: 00000000`74e00000 00000000`74e60000   C:\Windows\syswow64\SspiCli.dll
  ModLoad: 00000000`74df0000 00000000`74dfc000   C:\Windows\syswow64\CRYPTBASE.dll
  (684.e30): WOW64 breakpoint - code 4000001f (first chance)
  First chance exceptions are reported before any exception handling.
  This exception may be expected and handled.
  ModLoad: 74860000 748ac000   C:\Windows\SysWOW64\apphelp.dll
  ModLoad: 00000000`7c340000 00000000`7c396000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\msvcr71.dll
  ModLoad: 00000000`6d8a0000 00000000`6db4f000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\client\jvm.dll
  ModLoad: 00000000`76610000 00000000`76710000   C:\Windows\syswow64\USER32.dll
  ModLoad: 00000000`76c20000 00000000`76cb0000   C:\Windows\syswow64\GDI32.dll
  ModLoad: 00000000`74ee0000 00000000`74eea000   C:\Windows\syswow64\LPK.dll
  ModLoad: 00000000`76190000 00000000`7622d000   C:\Windows\syswow64\USP10.dll
  ModLoad: 00000000`747e0000 00000000`74812000   C:\Windows\SysWOW64\WINMM.dll
  ModLoad: 00000000`76af0000 00000000`76b50000   C:\Windows\SysWOW64\IMM32.DLL
  ModLoad: 00000000`76b50000 00000000`76c1c000   C:\Windows\syswow64\MSCTF.dll
  ModLoad: 00000000`74860000 00000000`748ac000   C:\Windows\SysWOW64\apphelp.dll
  ModLoad: 00000000`6d850000 00000000`6d85c000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\verify.dll
  ModLoad: 00000000`6d3d0000 00000000`6d3ef000   c:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\java.dll
  ntdll!NtTerminateProcess+0xa:
  00000000`775915da c3              ret
  </code></pre>
  
  <p>Finito! Java terminates printing this short message in the console window:</p>
  
  <pre><code>Invalid initial heap size: -Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file
  :../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper
  Could not create the Java virtual machine.
  </code></pre>
  
  <p>Can anyone shed some light on this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Following some comments below, I tend to think I have a problem with me powershell script. </p>
  
  <p>Indeed, as Jon Skeet suggested I have tried to run a HelloWorld java app from within the debugger with the same -XYZ params and it worked. And then came a comment by Codo, which made me think something is rotten with my powershell code.</p>
  
  <p>Here it is:</p>
  
  <pre><code>$env:JAVA_HOME='c:\Program Files (x86)\Java\jdk1.6.0_29'
  $Params="-Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper"
  windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;g;g" "$env:JAVA_HOME\bin\java.exe" $Params
  </code></pre>
  
  <p>The <code>$Params</code> seems to be passed as a single string to the java process. OK, so I expand it:</p>
  
  <pre><code>windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;g;g" "$env:JAVA_HOME\bin\java.exe" -Xms128M -Xmx512M -Xss1024K -Dlog4j.debug -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper
  </code></pre>
  
  <p>Now I get a different fatal error printed out by java:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: /debug
  Caused by: java.lang.ClassNotFoundException: .debug
          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
  Could not find the main class: .debug.  Program will exit.
  </code></pre>
  
  <p>What does it want from my life?</p>
  
  <p><strong>EDIT2</strong></p>
  
  <p>Changed the command line as per Codo's suggestion:</p>
  
  <pre><code>windbg -logo c:\dumps\dbg.log -QY -awow64exts -c "!sw;g;g" "$env:JAVA_HOME\bin\java.exe" -Xms128M -Xmx512M -Xss1024K -Dlog4j.debug=true -Dlog4j.configuration=file:../conf/log4j.xml -Ddozer.configuration=file:../conf/config.properties -jar bootstrapper.jar com.shunra.bootstrapper.guice.Bootstrapper
  </code></pre>
  
  <p>Now the error is:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: /debug=true
  Caused by: java.lang.ClassNotFoundException: .debug=true
          at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
  Could not find the main class: .debug=true.  Program will exit.
  </code></pre>
  
  <p>Which means the <code>-Dlog4j.debug=true</code> is interpreted as a class name, rather than JVM option. I do not understand what's going on.</p>