Linux - WSL
Helpful tips about using WSL
Helpful References
- https://learn.microsoft.com/en-us/windows/wsl/install
- https://itnext.io/using-wsl-2-to-develop-java-application-on-windows-8aac1123c59b
- https://itnext.io/%EF%B8%8Fusing-wls-2-and-wslg-for-development-on-windows-11-final-part-70661bb3788c
How can I check if Virtualization is enabled/disabled on my desktop/laptop?
Open Task Manager and go to “Performance” tab and under CPU, you will find information about Virtualization on your desktop/laptop. If it says Enabled, then Virtualization is turned on. However, if it says Disabled, then Virtualization is turned off.
How to explore WSL distribution’s file system using Windows File Explorer?
- Go to terminal in the WSL distribution and run this command
explorer.exe .
- The dot represents “current directory”.
Helpful WSL commands
Set wsl version to 2
wsl --set-default-version 2
To see a list of available Linux distributions available for download through the online store
wsl --list --online
To install a specific distro
wsl --install -d <Distribution Name>.
Check existing distros in your Windows computer that work with WSL
wsl --list --verbose
wsl -l -v
Make a specific instance the default distro for WSL
wsl --set-default ubuntu-docker
wsl -S ubuntu-docker
Run a new default wsl
wsl
Remove imported Linux distro on WSL with commands
wsl --list
wsl --unregister DISTRO-NAME
wsl --unregister Ubuntu
Stop running instances
wsl --terminate <Distribution Name>
wsl -t <Distribution Name>
To shutdown the current running distro
wsl --shutdown
Helpful tools to install in the host windows machine
- multiple terminal emulator like ConEmu (Windows 11 comes with the latest terminal with support for multiple tabs)
Helpful tools to install in WSL
- fix bashrc set-up
- neofetch
- emacs
- fix org-roam set-up
- browser
- ripgrep
- jdk
- maven
Running IntelliJ
I got this error when I wanted to run the intellij-idea-community for the first time:
CompileCommand: exclude com/intellij/openapi/vfs/impl/FilePartNodeRoot.trieDescend bool exclude = true
Start Failed
Internal error. Please refer to https://jb.gg/ide/critical-startup-errors
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
at java.desktop/java.awt.Color.<clinit>(Color.java:277)
at com.intellij.ide.ui.laf.IdeaLaf.<clinit>(IdeaLaf.java:24)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at com.intellij.idea.StartupUtil$preloadLafClasses$1.invokeSuspend(StartupUtil.kt:579)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: java.lang.UnsatisfiedLinkError: /snap/intellij-idea-community/409/jbr/lib/libawt_xawt.so: libXrender.so.1: cannot open shared object file: No such file or directory
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
at java.base/java.lang.Runtime.load0(Runtime.java:755)
at java.base/java.lang.System.load(System.java:1953)
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:315)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:285)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1989)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1388)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1386)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1385)
at java.desktop/java.awt.Toolkit.initStatic(Toolkit.java:1428)
at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1397)
at com.intellij.idea.StartupUtil$initAwtToolkit$1$1.invokeSuspend(StartupUtil.kt:485)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
... 4 more
-----
Your JRE: 17.0.5+1-b653.25 amd64 (JetBrains s.r.o.)
/snap/intellij-idea-community/409/jbr
Also, a UI exception occurred on an attempt to show the above message
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
at java.desktop/java.awt.Component.<clinit>(Component.java:632)
at com.intellij.idea.StartupErrorReporter.showMessage(StartupErrorReporter.java:85)
at com.intellij.idea.StartupErrorReporter.showMessage(StartupErrorReporter.java:39)
at com.intellij.idea.Main.main(Main.kt:65)
After installing gnome-software, like gnome-system-monitor that has some dependencies on X11-related packages, everything is fixed!