Monday, April 29, 2013

Eclipse No Java Virtual Machine was found Windows JRE JDK 64 32 bit Error

One of my reader was installing Eclipse in his Windows 7 x86 machine and emailed me about this error "A java Runtime Environment (JRE) or Java Development kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found". Before getting into details and trying to find root cause and solution of Eclipse Java Virtual Machine not found error, let's see some background about Eclipse. Eclipse is a popular Java IDE, which assist on coding, debugging and running Java program, but key point is, Eclipse itself need Java to launch and run. By default Eclipse scan your PATH and look for any JRE, if it founds suitable JRE than it runs otherwise it throws "A java Runtime Environment (JRE) or Java Development kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found". Now, In order to install JRE, you can either download JDK or a JRE from Oracle's Java download site. For Java programmers, I suggest to install JDK because it comes with bundled JRE.  Once you install JDK, its good to set your JAVA_HOME environment variable, and subsequently include JAVA_HOME/bin into your PATH. JAVA_HOME contains "java" command line utility which is what required by Eclipse to run. Alternatively you can install JRE on your windows 7 machine, and include its bin directory into PATH that contains javaw command, which can also run Eclipse or any Java program. By the way there is subtle difference between java and javaw, which is worth knowing. You can get "No Java virtual machine was found" error during fresh install or reinstalling Eclipse, but root cause always lies in PATH which is quite obvious with error itself.

x86 and x64 Eclipse, JRE and Windows confusion

Things get more complicated with increased popularity of 64-bit machines and x64 operating Systems e.g.. Windows 7 x64. Many of us knows that 64-bit JVM allows you to set larger heap size than 32 bit JVM, but from normal users perspective it adds more confusion. Now both Eclipse and Java is available for x86 and x64 architectures for Windows. Since many programmers think that same Java runs on multiple operating system e.g. Windows 8, Windows 7, Windows Vista, Windows XP or Windows Server 2008, Instead of downloading correct version of JDK they simply use the one they have earlier, potentially 32 bit JRE, or copied version of JDK or JRE which could also be potentially x86 JRE. So if you are running a Windows 7 x64 or Windows 8 desktop , you better download 64 bit JRE e.g. jre-7-windows-x64.exe or x64 JDK jdk-7u11-windows-x64.exe from http://www.oracle.com/technetwork/java/javase/downloads/. Once you have correct JDK or JRE, and Eclipse i.e. either all x86 or all x64, all remains is setting PATH for Java. Once you set PATH just open a command prompt windows and type echo %PATH% and check if it correct JRE or JDK is included in PATH. By the way if you have installed both 32 bit and 64 bit JDK than you should be careful which JDK or JRE comes first in PATH, because any Java program including Eclipse will pick the JRE which comes earlier in PATH. This also applies if you are running Eclipse in Linux operating system, you need to ensure whether Linux is x86 or x64 and subsequently download x86 or x64 Eclipse and JDK or JRE. By the way, If you are confused between these two, read difference between JDK and JRE.

Steps to troubleshoot Eclipse No Java Virtual Machine was found error

Eclipse No Java Virtual Machine was found Windows JRE JDK 64 32 bit ErrorHere is couple of things you can check in order to troubleshoot and fix Eclipse No Java Virtual Machine was found error. As error suggest, Eclipse is not able to find any JVM which comes with either JDK or JRE installation, and most likely you need to modify your PATH to fix this issue.

1) Find out whether you are running on x32 or x64 Windows or Linux operating system.
1) Check if you have JRE or JDK installed in your machine or not. If not than install correct JDK or JRE i.e. x86 or x64 JDK and JRE.

2) Check whether JRE or JDK is in your system PATH or not. If you are unsure than see this article to set PATH for Java in Windows and Linux
3) Check if both JRE and Eclipse comes as 32 bit and 64 bit flavour. If you are running on 64 bit Windows operating system e.g. Windows 7 x64  and trying to install Eclipse 64 bit version, than you need a 64 bit JRE or JDK.

4) Alternative if you are running on 32 bit Windows operating system e.g. Windows 7 x86 or Windows XP than you need to use 32 bit Eclipse and 32 bit JDK or JRE version to launch Eclipse.

5) If you have multiple JDK and JRE installed in your machine, and your PATH contains location to those JDK and JRE, than Eclipse will pick the first one from PATH. This can create issues if you are running 64 bit Eclipse, and 32 bit JDK comes earlier in PATH of your windows 7 machine.

That's all abour error "A java Runtime Environment (JRE) or Java Development kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found". Apparently this is simple error to fix, but when it comes especially when you have JDK and JRE installed and have included them in PATH, it becomes tricky and create confusion amoong users. Let us know if you have faced "Eclipse : No Java virtual machine was found" error before and how did you fix it.

1 comment :

Issac Balaji said...

great solution its working for me

Post a Comment