Checking Java version and installing via batch file/command line

Unusual situation the other day. I got asked to add an Intranet page with a guide to explain how end users can check the version (or versions) of Java they have installed. I thought to myself there has to be a better and more efficient way of doing this, and making it easier for the end user at the same time.

First I had the idea of pointing them to the official Java install test page at Sun Micro, or the more detailed and thorough page over at http://www.javatester.org/version.html. I thought this was a decent solution, until I found out that if a user has more than 1 version of Java installed then a users Web browser can be set to use a different version of Java than the one that might be getting used for other applications.

Second solution was to use a batch file that would show all versions of Java that were installed on a machine:

java -version
pause

This worked fine I thought. Just create a batch file, put it on an accessible network source and fire round an email with a link to it.

Third solution. I spoke to a friend who is great with Desktop Support/Windows/etc. He managed to write a script that checks the specific version of Java that was needed (in this case jre-1_5_0_18-windows-i586-p.exe) and if its not installed, installs it from a network resource.

@Echo off
cls
Echo Installing Java 1.5.0_18, Please be patient

set temp_file_a=c:\temp_a.txt
set net2=0
if exist %temp_file_a% del %temp_file_a% echo clear temp file

rem get java installations
regedit /e %temp_file_a% “HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Plug-in\1.5.0_18″
if exist %temp_file_a% set net2=1
echo checked registry

if %net2% == 0 echo Java 1.5.0_18 Not Installed if %net2% == 1 echo Java 1.5.0_18 Already Installed if %net2% == 1 goto ta05 echo.
echo Installing Java 1.5.0_18. Please be patient \\”jre-1_5_0_18-windows-i586-p.exe” /passive
:ta05

if exist %temp_file_a% del %temp_file_a% cls Echo Java 1.5.0_18 Installed.
pause

This got rolled out via a run once group policy for the 400 users required. From Web Developer to Desktop Support in 3 easy steps ;)









  • Archives

  • Meta

  • RSS Feed

    RSS
    Comments RSS