Quantcast
Channel: Active questions tagged windows-subsystem-for-linux - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2824

Command 'java' not found on WSL, even though 'java' command works in Powershell

$
0
0

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!


Viewing all articles
Browse latest Browse all 2824

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>