文章目錄
- Java
- 1.Windows
- 1.1 scoop方式安裝JDK
- 2.Linux
- 2.1 apt方式安裝JDK
- 2.1.1 切換JDK
- 2.1.2 驗證版本
- 2.1.3 原理
- Python
- 1.Windows
- 1.1 scoop方式安裝Python
- 1.2 uv方式安裝Python(推薦)
- 2.Linux
- 2.1 apt方式安裝Python
- 2.1.1 配置版本切換
- 2.1.2 切換Python
- 2.1.3 驗證版本
- 2.2 uv方式安裝Python
- 3.uv方式說明
- 3.1 查看版本列表
- 3.2 初始化項目
- 3.3 添加依賴
- 3.4 查看依賴
- 3.5 同步依賴
- NodeJS
- 1.Windows
- 1.1 scoop方式安裝NodeJS
- 1.2 nvm方式安裝NodeJS(推薦)
- 2.Linux
- 2.1 nvm方式安裝NodeJS(推薦)
- 3.nvm方式說明
- 3.1 安裝版本
- 3.2 查看版本列表
- 3.3 切換版本
- 3.4 驗證版本
- 配置國內源
- 1.apt國內源
- 2.pip國內源
- 3.maven和gradle國內源
Java
從圖中可以看出,下載8/11/17三個版本即可,其他版本按需下載。
從圖中可以看出,除了Oracle外,Amazon和Eclipse Adoptium都挺好。
來源:https://newrelic.com/resources/report/2024-state-of-the-java-ecosystem
1.Windows
1.1 scoop方式安裝JDK
scoop install corretto8-jdk corretto11-jdk corretto17-jdk
2.Linux
2.1 apt方式安裝JDK
apt install software-properties-common -y
apt install openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk -y
2.1.1 切換JDK
update-alternatives --config java
2.1.2 驗證版本
java -version
2.1.3 原理
# 入口: /usr/bin/java -> /etc/alternatives/java*
ll /usr/bin/java# 切換: /etc/alternatives/java -> /usr/lib/jvm/java-21-openjdk-amd64/bin/java*
ll /etc/alternatives/java# 版本目錄:/usr/lib/jvm
ll /usr/lib/jvm
Python
1.Windows
1.1 scoop方式安裝Python
scoop install python38 python39 python310 python311 python312 python313 python314
1.2 uv方式安裝Python(推薦)
scoop install uv
2.Linux
2.1 apt方式安裝Python
apt install software-properties-common -y
add-apt-repository ppa:deadsnakes/ppa
apt install python{3.7,3.8,3.9,3.10,3.11,3.12,3.13,3.14} -y
2.1.1 配置版本切換
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
update-alternatives --install /usr/bin/python python /usr/bin/python3.8 3
update-alternatives --install /usr/bin/python python /usr/bin/python3.9 4
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 5
update-alternatives --install /usr/bin/python python /usr/bin/python3.11 6
update-alternatives --install /usr/bin/python python /usr/bin/python3.12 7
update-alternatives --install /usr/bin/python python /usr/bin/python3.13 8
update-alternatives --install /usr/bin/python python /usr/bin/python3.14 9
2.1.2 切換Python
update-alternatives --config python
2.1.3 驗證版本
python --version
2.2 uv方式安裝Python
apt install uv
3.uv方式說明
uv python install python3.7 python3.8 python3.9 python3.10 python3.11 python3.12 python3.13 python3.14
3.1 查看版本列表
uv python list
3.2 初始化項目
uv init
3.3 添加依賴
uv add requests
3.4 查看依賴
uv tree
3.5 同步依賴
uv sync
NodeJS
1.Windows
1.1 scoop方式安裝NodeJS
scoop install nodejs16 nodejs17 nodejs18 nodejs19 nodejs20 nodejs21 nodejs22 nodejs23
1.2 nvm方式安裝NodeJS(推薦)
scoop install nvm bun
2.Linux
2.1 nvm方式安裝NodeJS(推薦)
apt install nvm bun
3.nvm方式說明
3.1 安裝版本
nvm install 23
nvm install 22
nvm install 21
nvm install 20
nvm install 19
nvm install 18
nvm install 17
nvm install 16
3.2 查看版本列表
nvm list
3.3 切換版本
nvm use 23
3.4 驗證版本
node -v
配置國內源
1.apt國內源
#--quiet
#-O file
wget -qO- https://gitee.com/duhongming/shell-script/raw/master/mirrors/apt-sources.sh | bash
2.pip國內源
-
清華賊快(推薦)
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ -
騰訊(備用)
https://mirrors.cloud.tencent.com/pypi/simple/ -
阿里賊慢還缺包
https://developer.aliyun.com/mirror/pypi -
豆瓣重定向到騰訊
https://pypi.doubanio.com/simple/
python -m pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple --upgrade pippip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple/
pip config set global.extra-index-url "https://mirrors.cloud.tencent.com/pypi/simple/ https://mirrors.aliyun.com/pypi/simple"
# 阿里有時候缺包
(venv) d@d:~/SourceCode/test-gpu$ pip3 install torch torchvision torchaudio --index-url https://developer.aliyun.com/mirror/pypi
Looking in indexes: https://developer.aliyun.com/mirror/pypi
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch# 豆瓣重定向到騰訊了
(venv) d@d:~/SourceCode/test-gpu$ pip3 install torch torchvision torchaudio --index-url https://pypi.doubanio.com/simple/
Looking in indexes: https://pypi.doubanio.com/simple/
Collecting torchDownloading https://mirrors.cloud.tencent.com/pypi/packages/d1/35/e8b2daf02ce933e4518e6f5682c72fd0ed66c15910ea1fb4168f442b71c4/torch-2.5.1-cp311-cp311-manylinux1_x86_64.whl (906.5 MB)
3.maven和gradle國內源
參考:https://developer.aliyun.com/mvn/guide
.m2/settings.xml
<mirrors><mirror><id>aliyunmaven</id><mirrorOf>central</mirrorOf><name>阿里云公共倉庫</name><url>https://maven.aliyun.com/repository/public</url></mirror><mirror><id>pentaho-public</id><name>Pentaho Public</name><mirrorOf>*</mirrorOf><url>http://nexus.pentaho.org/content/groups/omni/</url></mirror>
</mirrors>
\init.d\init.gradle
allprojects {repositories {mavenLocal()maven { name "Alibaba" ; url "https://maven.aliyun.com/repository/public" }mavenCentral()}buildscript { repositories { maven { name "Alibaba" ; url 'https://maven.aliyun.com/repository/public' }}}
}