Check if you have the correct java version set globally or not . It might be due to the java version being different in the place you are running the mvn commands.