2
votes

The environment user variable for JAVA_HOME is set to a 32 bit jdk on my machine at-"C:\Program Files (x86)\Java\jdk1.6.0_31" and the PATH includes JAVA_HOME. But when i check java -version from command prompt it shows 64bit version is running.

java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)

I need to run 32bit version, is there something i need to change?

2
maybe you need to change also the PATH variable? - dawww
Check your path variable, maybe there is an entry for 64bit version of jdk , before JAVA_HOME . If yes add entry for your JAVA_HOME before that, or remove 64bit if you dont need it from path entry. - Mustafa sabir
@dawww Not maybe! No OS considers the JAVA_HOME variable when simply running an executable. It is always the PATH variable that must contain the directory. - Seelenvirtuose
You should use 32-bit java.exe/javaw.exe to invoke the 32-bit JVM. - Yi Zhao

2 Answers

1
votes

You need to change your PATH variable. JAVA_HOME is a variable normally used by java programms. The PATH variable is used for all kind of executable programms (like java vm).

0
votes

A suggestion how to set the OS environment variables for development tools.

Consider having installed Java, Ant, and Maven. Consider having the following directory structure for these installations:

C:\
 |
 |--- Programs/
 |       |--- Java/
 |       |      |--- jdk7/
 |       |      |     |--- bin/
 |       |      |     |--- <other files and directories>
 |
 |--- Tools/
 |       |--- apache-ant/
 |       |        |--- bin/
 |       |        |--- <other files and directories>
 |       |--- apache-maven/
 |       |        |--- bin/
 |       |        |--- <other files and directories>

Then you should have the following three HOME variables:

JAVA_HOME = C:\Programs\Java\jdk7
ANT_HOME = C:\Tools\apache-ant
M2_HOME = C:\Tools\apache-maven

Your PATH variable then should look like this:

PATH = ...;%JAVA_HOME%\bin;%ANT_HOME%\bin;%M2_HOME%\bin;...

From now on you only need to change the HOME variables when versions change. And your OS always finds the tool you want to start.