Extracting Java Version via CMD


Recommended Posts

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"

[/CODE]

This exports code which looks like this:

post-180771-0-83914500-1358418131.png

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

Link to comment
Share on other sites

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%
[/CODE]

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.