1. 程式人生 > >WSL搭建Java開發環境

WSL搭建Java開發環境

安裝WSL Ubuntu 18.04

開啟WSL並在微軟應用市場安裝

(選)修改預設使用者為root,並修改使用者目錄

開啟PowerShell win+x, a

ubuntu1804.exe config --default-user root

執行bash並修改

vim /etc/passwd

(選)修改apt源,加快下載速度(注:修改的源可能會不存在)

# 備份
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 修改
vim /etc/apt/sources.list
# 完全代替修改為
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

Upgrade ubuntu

apt update && apt upgrade

Install xfce desktop

apt install xfce4

注:直接裝整個介面來執行需要圖形介面的app(或者自己單獨安裝需要的元件)

Specify the display server

~/.bashrc新增

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

startxfce4

(選)Fix powerline fonts rendering

Install the lastest version of Hack fonts.

(選)Fix Unicode fonts rendering

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

sudo apt-get install fonts-noto-cjk

(選)Install Chinese input method

1.Install fcitx

sudo apt-get install fcitx
sudo apt-get install fcitx-pinyin

2.Add the following command to your bashrc file

~/.bashrc新增

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

安裝開發軟體

安裝Java

簡單起見,直接apt install openjdk-8-jdk 或用Oracle的jdk

安裝idea

下載解壓

方便啟動,加入到PATH

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

安裝dbeaver

下載解壓

方便啟動,加入到PATH

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

安裝RedisDesktopManager

注:由於WSL不支援systemd,所以暫時無法使用snap安裝 下載原始碼(修改為最新的tag)

git clone --recursive https://github.com/uglide/RedisDesktopManager.git -b 0.9.8

# 需要c++11
apt install g++
# 安裝,不然有些函式找不到
apt install zlib1g-dev

cd src/
./configure
# 我不用qmake也成功
make && make install
cd /opt/redis-desktop-manager/
mv qt.conf qt.backup

方便啟動,加入到PATH

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

其他

安裝字型

  1. 複製字型到/usr/share/fonts/${自己新建的目錄}
  2. 執行fc-cache -f -v
  3. 參考link1, link2

參考文件