Fix sdkmanager java.lang.NoClassDefFoundError batchfile

You can try this solution

First open sdkmanager.bat with any text editor

Then find this line

  %JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%

And change it to this line

  %JAVA_EXE%" %DEFAULT_JVM_OPTS% --add-modules java.xml.bind %JAVA_OPTS% %SDKMANAGER_OPTS%

I hope this solves your problem.


I had the issue as default installation of java was v11

java -version
Should be : openjdk version "1.8.0_252"

Fix:
sudo apt-get install openjdk-8-jdk
Don't worry won't overwrite
Then switch to the correct version via
sudo update-alternatives --config java

confirm correct output from java -version

than run sdkmanager again.