1

I am currently using the Windows 10 20H1 (build 19041.153) with WSL2 enabled.

I have already configured git in WSL2 and managed to clone the repository to my C:/ drive. I have the oracle Java 8 installed on Windows and what I want to achieve is to run "make" command and "make && make install" in the WSL2, but use Java 8 from Windows - without installing it on WSL2.

Also, I would like to use IntelliJ IDEA on Windows and build the project there after executing "make". Is that possible?

I have created 2 symbolic links in WSL2 with the following:

sudo ln -s /mnt/c/Program\ Files\/Java/jre1.8.0_191/bin/java.exe /bin/java
sudo ln -s /mnt/c/Program\ Files\/Java/jre1.8.0_191/bin/javac.exe /bin/javac

The first one works fine, so that when I type in:

java -version

In WSL2 I get:

java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

but the

javac -version

provided me with:

Command 'javac' not found,

Any hints? Also, during "make && make install" I get an error:

make -s -f src/bios/script/Makefile realclean
make -s -f src/bios/script/Makefile packages
make -s -f src/bios/script/Makefile eclipse_classpath
make -s -f src/bios/script/Makefile codegeneration
make -s -f src/bios/script/Makefile everything
/bin/sh: 1: javac: not found
src/bios/script/Makefile:417: recipe for target 'everything' failed
make[1]: *** [everything] Error 127
src/bios/script/Makefile:249: recipe for target 'all' failed
make: *** [all] Error 2

I did not edit the files .profile or .bashrc - is that important?

  • 1
    You need to install the JDK (Java Development Kit) if you want `javac`. The JRE (Java Runtime Environment) only has the `java` interpreter. If you look in `C:\Program Files\Java\jre1.8.0_191\bin` do you see a `javac.exe` there? – MadScientist Mar 24 '20 at 18:22
  • 1
    IntelliJ IDEA doesn't support Java in WSL at the moment, please follow https://youtrack.jetbrains.com/issue/IDEA-223986 for updates. – CrazyCoder Mar 24 '20 at 18:46
  • @CrazyCoder thank you for the reply, do you know any other IDE that supports it, maybe eclipse? or is it better to install IntelliJ in WSL and start it from there? – Michał Kochanowicz Mar 24 '20 at 21:10
  • Using IntelliJ IDEA from the WSL is the valid option, I do it via https://sourceforge.net/projects/vcxsrv/ . – CrazyCoder Mar 24 '20 at 21:11
  • @MadScientist I can see I have 2 directories in Program Files: both JRE and JDK, I provided the wrong one in the path, my bad - I changed it and now its ok :) – Michał Kochanowicz Mar 24 '20 at 21:12
  • @CrazyCoder I installed it from the link you provided, do you have any information on how should I configure it now for intelliJ? – Michał Kochanowicz Mar 24 '20 at 21:32
  • 1
    See https://wsl-guide.kennethreitz.org/en/latest/gui.html. Install IntelliJ IDEA in WSL and run it using idea.sh after exporting DISPLAY environment. Make sure you have VcXsrv running on Windows. – CrazyCoder Mar 24 '20 at 21:38
  • @CrazyCoder works great! :) I have one issue left - on Windows I have both JDK 8 and 11, I have a batch file to change the JAVA_HOME accordingly and I can see when typing java -version and javac -version the change is reflected in both Windows and WSL2. However, I cannot execute "make && make install" in WSL2, it seems it tries to use Java 11 instead of 8, which is why it probably causes the error: javac: invalid source release: 11; even though javac -version provides me with 1.8.0; – Michał Kochanowicz Mar 25 '20 at 16:40
  • If `javac -version` is `1.8.0`, you can't use `11` source release. – CrazyCoder Mar 25 '20 at 19:17
  • @CrazyCoder yes, I should use java 8, but it seems "make" tries to use java 11 and it will fail with java 11 as for this project I need java 8. It seems that "make" tries to use java 11, even though javac -version is 1.8.0 – Michał Kochanowicz Mar 25 '20 at 19:37
  • `error: javac: invalid source release: 11;` means that you are using Java 8 and `-source 11` option which is not supported by JDK 1.8. – CrazyCoder Mar 25 '20 at 19:39
  • @CrazyCoder ok, now I have switched to Java 11 on Windows and javac -version provides me with 11, but on WSL2 it provides me with 1.8.0, I guess I messed something up – Michał Kochanowicz Mar 25 '20 at 19:53
  • @CrazyCoder, you asked in a comment if another IDE supports WSL. VSCode has native support for it. – Shmuel Kamensky Apr 28 '20 at 07:39

0 Answers0