Thursday, February 8, 2024

[SOLVED] CreateProcess error=193, %1 is not a valid Win32 application in WSL + IntellIJ in Windows env

Issue

I am trying to run a test case in WSL using IntellIJ in Windows. I am getting following error.

Error running 'InstanceAssignmentConfigUtilsTest': Cannot run program "\\wsl$\Ubuntu\usr\lib\jvm\java-11-openjdk-amd64\bin\java" (in directory "\\wsl$\Ubuntu\home\aditya0811\pinot\pinot-common"): CreateProcess error=193, %1 is not a valid Win32 application

The test case ran successfully using Windows terminal configured with Ubuntu. However I want to configure the IntellIJ with the WSL for debugging, i.e. the idea is to use WSL env for running Java and a windows application (here IntellIJ) for editing and debugging.

I wanted to know if I am missing any configurations, I looked around as many people have faced this issue but could not resolve this issue. I was not able to set up Run Target as mentioned here, since its only available in Ultimate edition.

IntellIJ

IntelliJ IDEA 2023.2.2 (Community Edition)
Build #IC-232.9921.47, built on September 13, 2023
Runtime version: 17.0.8+7-b1000.22 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4048M
Cores: 12
Registry:
    ide.experimental.ui=true


Kotlin: 232-1.9.0-IJ9921.47

IntellIJ Maven settings

Maven home path : \\wsl$\Ubuntu\opt\apache-maven-3.6.3
User settings file : \\wsl$\Ubuntu\home\aditya0811\.m2\settings.xml
Local repository : \\wsl$\Ubuntu\home\aditya0811\.m2\repository

IntellIJ Maven/Importing settings

JDK for importer (version 11.0.21) : \\wsl$\Ubuntu\usr\lib\jvm\java-11-openjdk-amd64

WSL env variables

M2_HOME = /opt/apache-maven-3.6.3
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

WSL

Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.133.1-microsoft-standard-WSL2 x86_64)

Solution

since you are using IDEA Community Edition, all the files under WLS are just like some files on a USB stick, so the IDEA just trying to use some Linux JDK binary to run the project under Windows OS, it's impossible because they are different(windows using java.exe but Linux is files like java). In this case, you should change your File project structure and change to a Windows version of JDK installed on the Windows system.

Another simple solution is that you can use https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps to run your IDEA Linux version under the WSL system.



Answered By - Jacky Liu
Answer Checked By - Clifford M. (WPSolving Volunteer)