On a system with WSL, new Java project dialog defaults to using WSL without making it clear it is doing so.

I noticed when creating a new Java project today that when I went to build it, it asked me to allow IntelliJ through the Windows firewall. I allowed private access, which is what I always do. I never allow public access. Then my build got stuck. I figured the build was stuck because of a race condition where it needed that access through the firewall to complete. So I ran the build again. This time, no firewall popup appeared, but the build still got stuck.

After googling around I found the page https://www.jetbrains.com/help/idea/how-to-use-wsl-development-environment-in-product.html which talks about how for WSL, you need to allow IntelliJ through the Windows firewall with public access. I thought this was strange, because at no point in creating my project did I choose to use WSL. I used the default JDK in the New Project dialog which was labelled "11 version 11.0.11". When I tried again to create a project, I clicked this drop down and noticed that it had a second entry too, labelled "adopt-openjdk-11 version 11.0.11". When I completed the dialog with this selection, added a hello world line, and tried to build and run my program, it worked fine.

I find it strange that IntelliJ IDEA is defaulting to some sort of WSL integration. This doesn't feel like how I used to use IntelliJ IDEA on Windows before. There wasn't even a warning that this was what it was going to do. There was no "WSL" etc in the label for that Project SDK dropdown. And there was no error that I saw until the build timed out and I saw the error "Abnormal build process termination: Cannot establish network connection from WSL to Windows host (could be blocked by firewall). More details: https://jb.gg/wsl-firewall".

0
6 comments

Could you please share the screenshot of Project Structure | SDKs for this JDK configuration that is causing the problem?

0

Sure.

This is what the new project dialog looks like:

Then my editor looks like this when I complete the dialog:

When I click on File -> Project Structure I see this:

What's strange here is that it says there's no SDK selected. If I click OK, it actually changes the state of my project. It seems like it unselected the SDK. Because now my editor looks like this:

It says "Project JDK is not defined" at the top int he blue bar. And if I click on the "Setup SDK" link in the blue bar, it brings up the dropdown:

If I select the first selection in that dropdown, my editor looks like this:

I don't have the the option to run my code (the green play symbol) but I do have the option to debug my code. If I click debug, I see this after expanding "Build" at the bottom:

After about 30 seconds, I see this:

 

0

You didn't provide a screenshot with the JDK configuration I asked for:

0

Ah sorry about that.

0

This JDK is clearly inside a WSL, I'd recommend renaming it to 11 (WSL) so that you can know it when creating projects.

0

By the way, I notice that in your screenshot example, you *do* have something appended to the SDK to indicate that it's a WSL SDK:

This would have solved the problem for me. The only problem here is that I didn't know IntelliJ was trying to use WSL when I created a new project. I'm not familiar at all with WSL in IntelliJ. I use VS Code when I want to code with WSL.

0

Please sign in to leave a comment.