How-to articles, tricks, and solutions about JVM

How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

To determine whether you are running in a 64-bit JVM or a 32-bit JVM from within a Java program, you can use the sun.arch.data.model system property.

How do I find out what keystore my JVM is using?

To find out which keystore the Java Virtual Machine (JVM) is using, you can use the javax.net.ssl.KeyManagerFactory class and the getDefaultAlgorithm method.

How do I set the proxy to be used by the JVM

To set the proxy to be used by the Java Virtual Machine (JVM), you can use the -Dhttp.proxyHost, -Dhttp.proxyPort, and -Dhttp.nonProxyHosts options when starting the JVM.

How to deal with "java.lang.OutOfMemoryError: Java heap space" error?

"java.lang.OutOfMemoryError: Java heap space" means that the application has exhausted the maximum heap space. To fix this error, you can try the following:

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

The java.lang.UnsupportedClassVersionError error is usually caused by trying to run a Java class that was compiled with a newer version of the Java compiler than the version of the JRE (Java Runtime Environment) that you are using.

How to get a thread and heap dump of a Java process on Windows that's not running in a console

To get a thread and heap dump of a Java process on Windows that is not running in a console, you can use the jstack and jmap tools that are included with the Java Development Kit (JDK).

What are the -Xms and -Xmx parameters when starting JVM?

The -Xms and -Xmx options are used to set the initial and maximum heap sizes, respectively, for the Java Virtual Machine (JVM).