Is it possible using a Windows batch file to determine if the version of Java (assuming 7) installed is the 32 bit version or the 64 bit version?
Asked
Active
Viewed 3,141 times
3
-
Is it just that it is installed, or in the path as well. I have many versions installed to support different projects – Rob Goodwin Mar 07 '13 at 23:15
-
2http://stackoverflow.com/a/2062263/1393766 – Pshemo Mar 07 '13 at 23:16
-
@RobGoodwin assuming it is installed - it is which version it is. – hawkeye Mar 07 '13 at 23:20
-
From what I've seen, most look for the existance of environment variables like JAVA_HOME – MadProgrammer Mar 07 '13 at 23:23
-
@MadProgrammer so you're saying parse the JAVA_HOME based on whether it is in the 32 bit Program Files directory or not... – hawkeye Mar 07 '13 at 23:25
-
@hawkeye That would one approach, but that will only tell you where `JAVA_HOME` points. You could also look at `ProgramFiles(x86)` and `ProgramFiles` to see if "Java\" exists – MadProgrammer Mar 07 '13 at 23:27
-
@hawkeye You can have more than one. Are you interested in figuring this information out for all installations? – Rob Goodwin Mar 07 '13 at 23:30
2 Answers
4
Here is a small windows script to get you started that will determine Java32 vs Java64 vs JavaNotInstalled.
Tweak as necessary...
@echo off
java -d64 -version >nul 2>&1
if errorlevel 1 goto maybe32bit
echo Java is 64 bit
goto EXIT
:maybe32bit
where java >nul 2>&1
if errorlevel 1 goto nojava
echo Java is 32 bit
goto EXIT
:nojava
echo Java is not installed
:EXIT

Java42
- 7,628
- 1
- 32
- 50
-
@WestFarmer - Be more specific and perhaps open a question with the specific symptoms. Then, add a pointer here to the question. – Java42 May 29 '16 at 16:08
-
1
0
Yes, it is possible. The bat file could run java -version
and parse the output.

JB Nizet
- 678,734
- 91
- 1,224
- 1,255