You are confusing two notions... JVM (Java Virtual Machine) reserved space VS max allowed space for an array.
You got this error because your JVM are not properly configured to create an array of such size. To do that, you can launch you JVM with some parameters like :
-Xms4G -Xmx4G
More infos : https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/jrdocs/refman/optionX.html
With these parameters, you will increase the size of your JVM, and so now you are able create very big arrays.
For information, the error text for max size array is (not the same as yours):
java.lang.OutOfMemoryError:
  Requested array size exceeds VM limit
You can have this error you exceed the limit size of an array. And this is "int" not "Integer", so theoretically it is 2^31-1 = 2147483647, which is Integer.MAX_VALUE. But some JVM has defined max array value as Integer.MAX_VALUE - 5
Hope my answer is somehow clear...
Edited:
And if it's still not working, maybe you can figure it out with these lines :
// Get current size of heap in bytes
long heapSize = Runtime.getRuntime().totalMemory();
// Get maximum size of heap in bytes. The heap cannot grow beyond this size.
// Any attempt will result in an OutOfMemoryException.
long heapMaxSize = Runtime.getRuntime().maxMemory();
// Get amount of free memory within the heap in bytes. This size will increase // after garbage collection and decrease as new objects are created.
long heapFreeSize = Runtime.getRuntime().freeMemory();
Or these tools: Jconsole, VisualVM.