The tools are now available to make development on Windows as easy and standard an development on Unix has been for the last several years. I couldn't find a great guide that covered a full setup for a Java developer, and I needed to do it a few times myself recently. This is a quick guide to get Windows 10 users with no devtools on their system set up with Windows Subsystem for Linux, JDK 11, maven, and the editor of their choice (with slight VSCode favoritism).
This section and the next is pretty much ripped from the official guide.
Press the Windows key and type "Windows Features" and open the "Turn Windows Features On or Off" option. Scroll down to the "Windows Subsystem for Linux" feature and check the box to enable it. You'll need to reboot your computer after this step.
Now hit that Windows key again and type "Microsoft Store" and open that bad boy up. Search the store for "Linux" and click the "Get the apps" option that comes up. Choose "Ubuntu" from the options that show up and click "Install" on that page.
Press the Windows key again and type/open "Ubuntu". This will trigger a bit of additional setup the first time.
It'll ask you to create a username and password for the subsystem, do so. Once you've done that you'll be dumped into
bash in your Ubuntu subsystem!
Note that your whole Windows C drive will be mounted at
/mnt/cin Ubuntu, so
ls /mnt/cshould look familiar.
Now we need a couple more tools to get the system Java ready.
sudo apt update will pull down updated mirrors for downloading applications from.
sudo apt install openjdk-11-jdk maven will install the Java Development Kit (necessary for any Java work) and Maven (a common build tool, feel free to substitute
gradle or something else).
I recommend using VSCode because it has a nice server set up so you can run VSCode in Windows while having it interact with your files in Ubuntu, but any editor will work. If you use something other than VSCode (
vim, Notepad++, SublimeText, Atom, etc) you'll likely want to do your development somewhere on your C drive such as
C:\code\project and access it from Ubuntu at
/mnt/c/code/project. With that said I'll move forward with VSCode setup.
Download VSCode for Windows and install it.
Start up VSCode in Windows and press
ctrl + shift + p, type "Install Extensions" and press enter. Type "windows subsystem" and click install on "Remote - WSL" by Microsoft. Once that's finished, close VSCode in Windows.
Close your Ubuntu bash window if you still have it open, and re-open it. Type
code .. This will set up VSCode's WSL server and launch VSCode back in Windows for you. Press
ctrl + shift + p, type "install extensions", press enter, and search for "java red hat", and install "Java Language Support" by Red Hat.
Done! You're all set up to develop a Java project in Ubuntu in WSL!
code .in the future to open VSCode in whatever directory you want, so you'll always open it with the Ubuntu <-> Windows connection set up.
- With your Ubuntu bash window open you can right click the title bar and select Properties. Here you can turn on "QuickEdit mode" and "copy/paste with Ctrl+Shift+C/Ctrl+Shift+V" to enable easy selection and copy/paste between Ubuntu and Windows. Now if you pin Ubuntu to your task bar it'll always start up with those options set.
- You should be able to get away with a lot just using
rm(remove a file),
mvn(java build tool). If you throw
-hon any of those commands you'll get a quick set of options. You can search for manpages for any of them for more detail.
- This free MIT resource covers a lot of computing basics that everyone should know. It's useful if you feel uncomfortable in Unix.
aptis the application installer on Ubuntu. You can
apt searchfor programs and
apt installto install them. Searching for help with apt should be easy, there's nothing different about the WSL Ubuntu version.