This post originated from an RSS feed registered with Java Buzz
by Javin Paul.
Original Post: How to find if JVM is 32 or 64 bit from Java program.
Feed Title: Javarevisited Blog
Feed URL: http://javarevisited.blogspot.com/feeds/posts/default?alt=rss
Feed Description: Blog on Java, Unix, Linux, FIX Protocol technology. I share my experience as tutorial, article, interview questions, programming, design etc.
You can find JVM bit size e.g. 32 bit or 64 bit by using either running java command from command prompt or by using System.getProperty() from Java program. Question is why do you want to know hardware or platform configuration while writing Java code which is supposed to write once and read anywhere(32 bit, 64 bit etc)? Yes we don't really need to know whether JVM is 32 bit or 64 bit more often but there are many situation when this matters
1)Since in 32 bit JVM maximum heap size in Java can not be more than 4GB (theoretically) , if you can get JVM version from script like running java command you can have different memory configuration for your application. Also if there is any specific JVM options which only applicable to 64 bit JVM than you can set those.