I am trying to execute Makefile as part of my course. It's a parser and lexer in CUP and Jflex, respectively. It is not possible to do it in Windows Powershell, so I was advised to use Linux, my colleague was also able to run it on Ubuntu's subsystem on Windows.
So I downloaded the ubuntu:
https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6?activetab=pivot:overviewtab from MS Store
Then allowed to use Linux subsystem in the Windows settings, however now, when I try to run make
in bash, I get this error:
mkdir -p bin
java -jar lib/jflex-1.8.2.jar -d src/ src/Lexer.lex
make: java: Command not found
make: *** [Makefile:10: bin/SC.class] Error 127
Do you know why is that? My colleague did this on desktop, and apprently after doing make for the first time, the bash asked him whether he wanted to have JDK 8 installed, and after the bash installed it, it worked. But now, when he is trying to do it on his windows laptop, he has the same problem as me. Also note, that I have JDK 15 installed on my machine
You can run all the Windows 10 executables including Java from within WSL, but note that GNU/Linux won't tack on ".EXE" by default as Windows does (Windows uses PATHEXT=.COM;.EXE;.BAT...
for this purpose), and WSL won't necessarily have the Windows binaries on the bash PATH.
For example my installation of JDK14 is at Windows C:\java\jdk-14
== WSL /mnt/c/java/jdk-14
:
/mnt/c/java/jdk-14/bin/java -version
=> Fails with
bash: /mnt/c/java/jdk-14/bin/java: No such file or directory
/mnt/c/java/jdk-14/bin/java.exe -version
java version "14" 2020-03-17
You can fix your makefile / run issue with one or more of the following:
Try setting your WSL bash PATH to contain the Windows JDK and edit your makefile command to java.exe
not java
export PATH=/mnt/c/java/jdk-14/bin:$PATH java.exe -version => Should work
Alternatively symbolic link java
to java.exe
- assuming PATH contains .
export PATH=.:$PATH ln -s /mnt/c/java/jdk-14/bin/java.exe java java -version => Should work
Install Java on WSL - the link suggested by @Samuel V. would work, although if you want specific JDK it is easier to download a reference Linux release .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.