This topic probably is a common one, but when looking online I didn't see much that related to my case, since I'm not running a normal ubuntu, but rather WSL (Windows Subsystem for Linux).
So my problem is that I switched from java 8 to java 17 recently (I required java 8 for a course), but I noticed that on ubuntu terminals, java -version still showed openjdk-1.8.(something), rather than jdk-17 or something like that.
So I thought that uninstalling openjdk would do the trick, which I did with sudo apt-get autoremove openjdk-8-jre. However, now typing java in an ubuntu terminal doesn't work anymore at all, and shows: Command 'java' not found, but can be installed with: .... But I fear that installing it with one of these commands will install a new version of java, rather than using the one that's already installed.
I have set the JAVA_HOME variable to the java installation directory, which is mnt/c/Program Files/Java/jdk-17.0.1, but the space in Program Files does seem to be a problem.
How can I fix this? I usually prefer using a bash terminal than Powershell or cmd because I know the commands better, so not being able to use java or javac in bash is an issue for me. Thanks!