When you select a java version in your project settings:
You have to make sure you have the correct java sdk selected here, too, under "Edit > Preferences"
You can read more about the installation here: https://docs.mendix.com/refguide/jdk-installation/