WSL搭建Java开发环境

Java develop enviroment for WSL 1

Posted by Archon on October 12, 2018

安装WSL Ubuntu 18.04

开启WSL并在微软应用市场安装


修改默认用户为root,并修改用户目录(选)

打开PowerShell win+x, a

1
ubuntu1804.exe config --default-user root

运行bash并修改

1
vim /etc/passwd

修改apt源,加快下载速度(选)

注:时间久了,源可能会不存在

1
2
3
4
5
6
7
8
9
# 备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 修改
vim /etc/apt/sources.list
# 完全代替修改为
deb http://mirrors.aliyun.com/ubuntu/ bionic main
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main

Upgrade ubuntu

1
apt update && apt upgrade

Install xfce desktop

注:直接安装整个xfce4桌面来安装所需的图形界面组件(idea,eclipse等需要图形界面,或者自己单独安装需要的组件)

1
apt install xfce4

Specify the display server

~/.bashrc添加

1
2
export DISPLAY=:0.0
export LIBGL_ALWAYS_INDIRECT=1

Install VcXsrv

Install the lastest version of VcXsrv.


Open display server

Open XLaunch, choose “One large window” or “One large window without titlebar” and set the “display number” to 0. Other settings leave as default and finish the configuration.


Run xfce desktop

运行bash

1
startxfce4

Fix powerline fonts rendering(选)

Install the lastest version of Hack fonts.


Fix Unicode fonts rendering(选)

1
2
3
4
sudo apt-get install fonts-noto
sudo apt-get install fonts-noto-hinted
sudo apt-get install fonts-noto-mono
sudo apt-get install fonts-noto-unhinted

Fix Chinese fonts rendering(选)

1
sudo apt-get install fonts-noto-cjk

Install Chinese input method(选)

1.Install fcitx

1
2
sudo apt-get install fcitx
sudo apt-get install fcitx-pinyin

2.Add the following command to your bashrc file

~/.bashrc添加

1
2
3
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx

安装开发软件

安装Java

简单起见,直接apt install openjdk-8-jdk 或用Oracle的jdk

安装idea

下载解压

方便启动,加入到PATH

1
2
3
# idea
export IDEA_HOME=/opt/idea/current
export PATH=$IDEA_HOME/bin:$PATH

安装dbeaver

下载解压

方便启动,加入到PATH

1
2
3
4
# dbeaver
export DBEAVER_HOME=/opt/dbeaver/current
export PATH=$DBEAVER_HOME:$PATH

安装RedisDesktopManager

完整版(给个star):RedisDesktopManager-Linux-WSL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# need to upgrade
apt update && apt upgrade

# change to latest tag
git clone --recursive https://github.com/uglide/RedisDesktopManager.git -b 0.9.8

cd RedisDesktopManager/
cd src/
./configure
qmake
make
make install

cd /opt/redis-desktop-manager/
mv qt.conf qt.backup

# optional, reduces rdm size 30MB+ to 2MB+
strip rdm

方便启动,加入到PATH

1
2
3
# RDM
export RDM_HOME=/opt/redis-desktop-manager
export PATH=$RDM_HOME:$PATH

其他

汇总需要添加到.bashrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
export DISPLAY=:0.0
export LIBGL_ALWAYS_INDIRECT=1

#pinyin
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx

# dbeaver
export DBEAVER_HOME=/opt/dbeaver/current
export PATH=$DBEAVER_HOME:$PATH

# idea
export IDEA_HOME=/opt/idea/current
export PATH=$IDEA_HOME/bin:$PATH

# RDM
export RDM_HOME=/opt/redis-desktop-manager
export PATH=$RDM_HOME:$PATH

Git修改信息和记住密码

1
2
3
git config --global user.name archon
git config --global user.email qq349074225@live.com
git config --global credential.helper store

安装字体

  1. 复制字体到/usr/share/fonts/${自己新建的目录}
  2. 运行fc-cache -f -v
  3. 参考link1, link2

参考文档

RedisDesktopManager-Linux-WSL wsl-tutorial redisdesktop linux redisdesktop build fail


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.