Let jenv manage multiple version of java.
brew install jenv
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
or echo to .zshrc(depends on your shell, for chechking use "echo $SHELL")
jenv add /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
jenv enable-plugin maven
jenv enable-plugin export
jenv local 10.0