Jump to content



Photo

Extracting Java Version via CMD


  • Please log in to reply
1 reply to this topic

#1 CPressland

CPressland

    www.absolute.com

  • Tech Issues Solved: 3
  • Joined: 16-September 06
  • Location: England
  • OS: OS X Mavericks

Posted 17 January 2013 - 10:24

Hey,

I'm currently working on migrating versions of Java to the latest build and am currently trying to do some custom reporting back to my Inventory Server; currently on OS X I'm running a shell script which looks like this:

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version 2>&1 | grep "java version" | awk '{print $3}' | sed -e "s/\"//g"


This exports code which looks like this:

Screen Shot 2013-01-17 at 10.22.03.png

So what I need is a Batch Script which will do the exact same on Windows. Any ideas?


#2 OP CPressland

CPressland

    www.absolute.com

  • Tech Issues Solved: 3
  • Joined: 16-September 06
  • Location: England
  • OS: OS X Mavericks

Posted 18 January 2013 - 15:45

Just in case anybody in the future needs this:

@echo off
setlocal

set VERSION6="1.6.0_21"
for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
set JAVAVER=%%g
)
set JAVAVER=%JAVAVER:"=%
@echo %JAVAVER%
endlocal
@exit %JAVAVER%




Click here to login or here to register to remove this ad, it's free!