Skip to content

Commit

Permalink
Add check for Java (Azure#3007)
Browse files Browse the repository at this point in the history
  • Loading branch information
pragnagopa authored Jun 14, 2018
1 parent 47bd36a commit 74f77c4
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Check([string] $componentName, [string] $verstr, [Version] $requiredVer
{
$verStr = $verStr.Substring(1)
}

# Version could be a beta, like 2.1.200-preview-007576
$x = $verstr;
$idxDash = $x.IndexOf('-')
Expand Down Expand Up @@ -92,6 +92,25 @@ if (-Not $ok) {
Write-Host
}

# Check Java
$javaFullVersion = & "java" -version 2>&1
$javaVersion = $javaFullVersion[0].toString().Split(' ')
$javaVersion = $javaVersion[2].Trim('"')
$underscoreIndex = $javaVersion.IndexOf('_')
$actualVersion = $javaVersion.Substring(0, $underscoreIndex)
$ok = Check "java" $actualVersion ([Version]::Parse("1.8.0"))

if (-Not $ok) {
Write-Host " You can udpate java by downloading from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"
Write-Host
}
$ok = Test-Path 'env:JAVA_HOME'
if (-Not $ok) {
Write-Host "JAVA_HOME Environment variable not set. Set it to JDK folder. Example c:\Program Files\Java\jdk1.8.0_171" -ForegroundColor Red
Write-Host
}


# See here for hints on doing Devenv detection:
# https://stackoverflow.com/questions/42435592/determining-installed-visual-studio-path-for-2017
# Or here: https://stackoverflow.com/questions/40694598/how-do-i-call-visual-studio-2017-rcs-version-of-msbuild-from-a-bat-file/40702534#40702534

0 comments on commit 74f77c4

Please sign in to comment.