Issue
I tried to install JDK on WSL Kali Linux. I followed fieldju answer on Installing Oracle JDK on Windows subsystem for Linux. It Succeeded, javac, java instructions worked fine.
But whenever I opened Kali,
-bash: /etc/profile.d/oraclejdk.sh: line 3: syntax error near unexpected token `('
-bash: /etc/profile.d/oraclejdk.sh: line 3: ` export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/WindowsApps/KaliLinux.54290C8133FEE_1.1.9.0_x64__ey8k8hqnwqnmg:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0/:/mnt/c/windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Intel/WiFi/bin/:/mnt/c/Program Files/Common Files/Intel/WirelessCommon/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/PowerShell/6/:/mnt/c/Users/User/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/User/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/Bandizip/:/mnt/c/Program Files/Java/jdk-12.0.1/bin:/mnt/c/Users/User/AppData/Local/GitHubDesktop/bin:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin'
This error comes. How can I resolve this problem?
This is my /etc/profile.d/oraclejdk.sh file
Solution
Based on the error message that bash gives for your /etc/profile.d/oraclejdk.sh it looks like you just need to double-quote the entire value assigned to your PATH variable.
Instead of this:
export PATH=/usr/local/sbin:/usr/local/bin...
Try this:
export PATH="/usr/local/sbin:/usr/local/bin..."
Note that double quotes are required because some of your folder names have white space. As a result bash sees everything after the first space as another expression and not part of the PATH value. Also the "(" character has special meaning to bash so it needs to be double quoted also.
Answered By - Don