File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ function Invoke-AutoScan {
48
48
49
49
# Ask user if java.exe should be added to the list
50
50
foreach ($java in $javaExecutables ) {
51
- $version = Get-JavaVersion $java
51
+ $version = Get-JavaMajorVersion $java
52
52
if ($acceptDefaults ) {
53
53
Invoke-Add $config $false $version ($java -replace " \\bin\\java\.exe$" , " " )
54
54
} else {
Original file line number Diff line number Diff line change @@ -22,4 +22,16 @@ function Get-JavaVersion {
22
22
$version = (Get-Command $javaexe | Select-Object - ExpandProperty Version).toString()
23
23
$version = $version -replace " (?>\.0)*(?!.+)" , " " # Remove trailing zeros
24
24
return $version
25
+ }
26
+
27
+ function Get-JavaMajorVersion {
28
+ param (
29
+ [Parameter (Mandatory = $true )][string ]$javaexe
30
+ )
31
+ $version = Get-JavaVersion $javaexe
32
+ $endIndex = $version.IndexOf (" ." )
33
+ if ($version.StartsWith (" 1." )) {
34
+ $endIndex = $version.IndexOf (" ." , $endIndex + 1 )
35
+ }
36
+ return $version.Substring (0 , $endIndex )
25
37
}
You can’t perform that action at this time.
0 commit comments