Repository: flutter
Issue: Flutter doctor uses wrong path to determine the Java version: Cannot execute /wrong/path/to/java to determine the version.
Labels: tool,t: flutter doctor,platform-linux,P2,team-tool,triaged-tool

I installed flutter using snap
`$ sudo snap install flutter --classic`

Here is my environment:
```
$ lsb_release -a
No LSB modules are available.
Distributor ID: Neon
Description:    KDE neon User - 5.25
Release:        20.04
Codename:       focal
```
```
$ arch 
x86_64
```
```
$ echo $JAVA_HOME
/home/USER/.sdkman/candidates/java/8.332.08.1-amzn
```
```
$ sdk current java 
Using java version 8.332.08.1-amzn
```
```
$ which java
/home/USER/.sdkman/candidates/java/8.332.08.1-amzn/bin/java
```
```
$ java -version
openjdk version "1.8.0_332"
OpenJDK Runtime Environment Corretto-8.332.08.1 (build 1.8.0_332-b08)
OpenJDK 64-Bit Server VM Corretto-8.332.08.1 (build 25.332-b08, mixed mode)
```
Here is the `flutter doctor -v` report:
```
[✓] Flutter (Channel stable, 3.0.5, on KDE neon User - 5.25 5.15.0-41-generic, locale en_US.UTF-8)
    • Flutter version 3.0.5 at /home/USER/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (2 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/USER/Databank/Android/Sdk/
    • Platform android-32, build-tools 30.0.2
    • Java binary at: /home/USER/.sdkman/candidates/java/8.0.222-amzn/bin/java
    ✗ Cannot execute /home/USER/.sdkman/candidates/java/8.0.222-amzn/bin/java to determine the version

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
    • IntelliJ at /home/USER/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/221.6008.13
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.69.2)
    • VS Code at /usr/share/code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • KDE neon User - 5.25 5.15.0-41-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.134

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.
```

**How can I solve the java verion error "`Cannot execute /home/USER/.sdkman/candidates/java/8.0.222-amzn/bin/java to determine the version`" reported?**
I don't even have that java version (8.0.222-amzn) installed in my system
```
$ sdk list java
================================================================================
Available Java Versions for Linux 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 Corretto      |     | 18.0.2       | amzn    |            | 18.0.2-amzn         
               |     | 18.0.1       | amzn    |            | 18.0.1-amzn         
               |     | 17.0.4       | amzn    |            | 17.0.4-amzn         
               |     | 17.0.3.6.1   | amzn    | installed  | 17.0.3.6.1-amzn     
               |     | 17.0.0.35.1  | amzn    |            | 17.0.0.35.1-amzn    
               |     | 11.0.16      | amzn    |            | 11.0.16-amzn        
               |     | 11.0.15.9.1  | amzn    | installed  | 11.0.15.9.1-amzn    
               |     | 11.0.12.7.1  | amzn    |            | 11.0.12.7.1-amzn    
               | >>> | 8.332.08.1   | amzn    | installed  | 8.332.08.1-amzn     
               |     | 8.0.342      | amzn    |            | 8.0.342-amzn        
 Dragonwell    |     | 17.0.3       | albba   |            | 17.0.3-albba        
               |     | 11.0.15      | albba   |            | 11.0.15-albba       
               |     | 11.0.12.8    | albba   |            | 11.0.12.8-albba     
               |     | 8.8.9        | albba   |            | 8.8.9-albba         
               |     | 8.0.332      | albba   |            | 8.0.332-albba       
 Gluon         |     | 22.1.0.1.r17 | gln     |            | 22.1.0.1.r17-gln    
               |     | 22.1.0.1.r11 | gln     |            | 22.1.0.1.r11-gln    
 GraalVM       |     | 22.1.0.r17   | grl     | installed  | 22.1.0.r17-grl      
               |     | 22.1.0.r11   | grl     |            | 22.1.0.r11-grl      
               |     | 22.0.0.2.r17 | grl     |            | 22.0.0.2.r17-grl    
               |     | 22.0.0.2.r11 | grl     |            | 22.0.0.2.r11-grl    
               |     | 21.3.2.r17   | grl     |            | 21.3.2.r17-grl      
               |     | 21.3.2.r11   | grl     |            | 21.3.2.r11-grl      
               |     | 21.3.1.r8    | grl     |            | 21.3.1.r8-grl       
               |     | 21.2.0.r8    | grl     |            | 21.2.0.r8-grl       
               |     | 21.1.0.r8    | grl     |            | 21.1.0.r8-grl       
               |     | 20.3.6.r11   | grl     |            | 20.3.6.r11-grl      
               |     | 20.3.3.r8    | grl     |            | 20.3.3.r8-grl       
               |     | 20.3.2.r8    | grl     |            | 20.3.2.r8-grl       
               |     | 19.3.6.r11   | grl     |            | 19.3.6.r11-grl      
               |     | 19.3.6.r8    | grl     |            | 19.3.6.r8-grl       
 Java.net      |     | 20.ea.7      | open    |            | 20.ea.7-open        
               |     | 19.ea.32     | open    |            | 19.ea.32-open       
               |     | 19.ea.1.pma  | open    |            | 19.ea.1.pma-open    
               |     | 18.0.2       | open    |            | 18.0.2-open         
               |     | 18.0.1.1     | open    |            | 18.0.1.1-open       
               |     | 11.0.12      | open    |            | 11.0.12-open        
               |     | 11.0.11      | open    |            | 11.0.11-open        
               |     | 11.0.10      | open    |            | 11.0.10-open        
               |     | 11.0.2       | open    |            | 11.0.2-open         
               |     | 8.0.302      | open    |            | 8.0.302-open        
               |     | 8.0.292      | open    |            | 8.0.292-open        
               |     | 8.0.282      | open    |            | 8.0.282-open        
               |     | 8.0.265      | open    |            | 8.0.265-open        
 Liberica      |     | 18.0.2.fx    | librca  |            | 18.0.2.fx-librca    
               |     | 18.0.2       | librca  |            | 18.0.2-librca       
               |     | 18.0.1.1.fx  | librca  |            | 18.0.1.1.fx-librca  
               |     | 18.0.1.1     | librca  |            | 18.0.1.1-librca     
               |     | 17.0.4.fx    | librca  |            | 17.0.4.fx-librca    
               |     | 17.0.4       | librca  |            | 17.0.4-librca       
               |     | 17.0.3.1.fx  | librca  |            | 17.0.3.1.fx-librca  
               |     | 17.0.3.1     | librca  |            | 17.0.3.1-librca     
               |     | 11.0.16.fx   | librca  |            | 11.0.16.fx-librca   
               |     | 11.0.16      | librca  |            | 11.0.16-librca      
               |     | 11.0.15.fx   | librca  |            | 11.0.15.fx-librca   
               |     | 11.0.15.1.fx | librca  |            | 11.0.15.1.fx-librca 
               |     | 11.0.15.1    | librca  |            | 11.0.15.1-librca    
               |     | 8.0.342.fx   | librca  |            | 8.0.342.fx-librca   
               |     | 8.0.342      | librca  |            | 8.0.342-librca      
               |     | 8.0.333.fx   | librca  |            | 8.0.333.fx-librca   
               |     | 8.0.333      | librca  |            | 8.0.333-librca      
               |     | 8.0.332.fx   | librca  |            | 8.0.332.fx-librca   
 Liberica NIK  |     | 22.1.r17     | nik     |            | 22.1.r17-nik        
               |     | 22.1.r11     | nik     |            | 22.1.r11-nik        
               |     | 22.0.0.2.r17 | nik     |            | 22.0.0.2.r17-nik    
               |     | 22.0.0.2.r11 | nik     |            | 22.0.0.2.r11-nik    
               |     | 21.3.2.r17   | nik     |            | 21.3.2.r17-nik      
               |     | 21.3.2.r11   | nik     |            | 21.3.2.r11-nik      
               |     | 21.2         | nik     |            | 21.2-nik            
               |     | 21.1         | nik     |            | 21.1-nik            
               |     | 21.0.0.2.r11 | nik     |            | 21.0.0.2.r11-nik    
               |     | 21.0.0.2     | nik     |            | 21.0.0.2-nik        
 Mandrel       |     | 22.1.0.0.r17 | mandrel |            | 22.1.0.0.r17-mandrel
               |     | 22.1.0.0.r11 | mandrel |            | 22.1.0.0.r11-mandrel
               |     | 22.0.0.2.r17 | mandrel |            | 22.0.0.2.r17-mandrel
               |     | 22.0.0.2.r11 | mandrel |            | 22.0.0.2.r11-mandrel
               |     | 21.3.2.0.r17 | mandrel |            | 21.3.2.0.r17-mandrel
               |     | 21.3.2.0.r11 | mandrel |            | 21.3.2.0.r11-mandrel
               |     | 21.3.1.1.r17 | mandrel |            | 21.3.1.1.r17-mandrel
               |     | 21.3.1.1.r11 | mandrel |            | 21.3.1.1.r11-mandrel
               |     | 21.3.1.0.r17 | mandrel |            | 21.3.1.0.r17-mandrel
               |     | 21.3.1.0.r11 | mandrel |            | 21.3.1.0.r11-mandrel
               |     | 21.3.0.0     | mandrel |            | 21.3.0.0-mandrel    
               |     | 21.2.0.2     | mandrel |            | 21.2.0.2-mandrel    
               |     | 20.3.3.0     | mandrel |            | 20.3.3.0-mandrel    
 Microsoft     |     | 17.0.3       | ms      |            | 17.0.3-ms           
               |     | 11.0.15      | ms      |            | 11.0.15-ms          
 Oracle        |     | 18.0.2       | oracle  |            | 18.0.2-oracle       
               |     | 18.0.1       | oracle  |            | 18.0.1-oracle       
               |     | 17.0.4       | oracle  |            | 17.0.4-oracle       
               |     | 17.0.3       | oracle  |            | 17.0.3-oracle       
 SapMachine    |     | 18.0.2       | sapmchn |            | 18.0.2-sapmchn      
               |     | 18.0.1.1     | sapmchn |            | 18.0.1.1-sapmchn    
               |     | 17.0.4       | sapmchn |            | 17.0.4-sapmchn      
               |     | 17.0.3       | sapmchn |            | 17.0.3-sapmchn      
               |     | 17.0.3.0.1   | sapmchn |            | 17.0.3.0.1-sapmchn  
               |     | 17.0.2       | sapmchn |            | 17.0.2-sapmchn      
               |     | 11.0.16      | sapmchn |            | 11.0.16-sapmchn     
               |     | 11.0.15      | sapmchn |            | 11.0.15-sapmchn     
               |     | 11.0.15.0.1  | sapmchn |            | 11.0.15.0.1-sapmchn 
               |     | 11.0.14      | sapmchn |            | 11.0.14-sapmchn     
               |     | 11.0.14.1    | sapmchn |            | 11.0.14.1-sapmchn   
 Semeru        |     | 18.0.1.1     | sem     |            | 18.0.1.1-sem        
               |     | 17.0.3       | sem     |            | 17.0.3-sem          
               |     | 11.0.15      | sem     |            | 11.0.15-sem         
               |     | 8.0.332      | sem     |            | 8.0.332-sem         
 Temurin       |     | 18.0.2       | tem     |            | 18.0.2-tem          
               |     | 18.0.1       | tem     |            | 18.0.1-tem          
               |     | 17.0.4       | tem     |            | 17.0.4-tem          
               |     | 17.0.3       | tem     |            | 17.0.3-tem          
               |     | 11.0.16      | tem     |            | 11.0.16-tem         
               |     | 11.0.15      | tem     |            | 11.0.15-tem         
               |     | 8.0.332      | tem     |            | 8.0.332-tem         
 Trava         |     | 11.0.15      | trava   |            | 11.0.15-trava       
               |     | 11.0.9       | trava   |            | 11.0.9-trava        
               |     | 8.0.282      | trava   |            | 8.0.282-trava       
               |     | 8.0.232      | trava   |            | 8.0.232-trava       
 Zulu          |     | 18.0.2       | zulu    |            | 18.0.2-zulu         
               |     | 18.0.1       | zulu    |            | 18.0.1-zulu         
               |     | 18.0.1.fx    | zulu    |            | 18.0.1.fx-zulu      
               |     | 17.0.4       | zulu    |            | 17.0.4-zulu         
               |     | 17.0.3       | zulu    |            | 17.0.3-zulu         
               |     | 17.0.3.fx    | zulu    |            | 17.0.3.fx-zulu      
               |     | 11.0.16      | zulu    |            | 11.0.16-zulu        
               |     | 11.0.15      | zulu    |            | 11.0.15-zulu        
               |     | 11.0.15.fx   | zulu    |            | 11.0.15.fx-zulu     
               |     | 8.0.342      | zulu    |            | 8.0.342-zulu        
               |     | 8.0.332      | zulu    |            | 8.0.332-zulu        
               |     | 8.0.332.fx   | zulu    |            | 8.0.332.fx-zulu     
               |     | 7.0.352      | zulu    |            | 7.0.352-zulu        
               |     | 7.0.342      | zulu    |            | 7.0.342-zulu        
               |     | 6.0.119      | zulu    |            | 6.0.119-zulu        
================================================================================
Omit Identifier to install default version 17.0.3-tem:
    $ sdk install java
Use TAB completion to discover available versions
    $ sdk install java [TAB]
Or install a specific version by Identifier:
    $ sdk install java 17.0.3-tem
Hit Q to exit this list view
================================================================================

```

Thx in advance