'Unable to launch uiautomatorviewer tool

I am getting the below error while attempting to launch the UI Automator Viewer tool via command prompt.

C:\Users\getta\AppData\Local\Android\Sdk\tools\bin>uiautomatorviewer -Djava.ext.dirs=..\lib\x86_64;..\lib is not supported. Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

I was googling and it suggested to downgrade Java to v8...any other workarounds apart from that??



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source