You can update the path
Open the terminal and run the following command to edit the .bashrc file:
nano ~/.bashrc
Look for any lines that incorrectly add Java to your PATH and remove any that reference /javac/bin/java.
export PATH=$PATH:/usr/lib/jvm/jdk-21.0.5-oracle-x64/bin
Save and Reload the file
source ~/.bashrc
Run Flutter doctor again to confirm your environment
flutter doctor -v
N/B: If you have Android Studio installed, ensure that it is pointing to the correct JDK . https://www.geeksforgeeks.org/how-to-set-java-sdk-path-in-android-studio/