> jenv global 1.8.0.25 > java -version java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
设置本地文件夹Java版本
1 2 3 4 5
> jenv local 1.8.0.25 > java -version java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! export SDKMAN_DIR="$HOME/.sdkman" [[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source"$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk list ================================================================================ Available Candidates ================================================================================ q-quit /-search down j-down ?-search up k-up h-help -------------------------------------------------------------------------------- ... -------------------------------------------------------------------------------- Java (21.0.3-tem) https://projects.eclipse.org/projects/adoptium.temurin/
Java Platform, Standard Edition (or Java SE) is a widely used platform for development and deployment of portable code for desktop and server environments. Java SE uses the object-oriented Java programming language. It is part of the Java software-platform family. Java SE defines a wide range of general-purpose APIs – such as Java APIs for the Java Class Library – and also includes the Java Language Specification and the Java Virtual Machine Specification.
================================================================================ + - local version * - installed > - currently in use ================================================================================ ```
## 使用当前版本
选择一个版本在**当前命令行**生效
```sh $ sdk use scala 3.4.2
全局版本
设置全局默认版本
1
$ sdk default scala 3.4.2
查看当前版本
1 2
$ sdk current java Using java version 21.0.3-tem
查看所有sdk的当前版本
1 2 3 4 5
$ sdk current Using: groovy: 4.0.21 java: 21.0.3-tem scala: 3.4.2
环境命令
可以使用环境命令加载项目根目录下.sdkmanrc 文件中的SDK版本
1
$ sdk env init
.sdkmanrc 内容如下:
1 2 3
# Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below java=21.0.3-tem
可以查看当前使用的环境版本
1 2
$ sdk env Using java version 21.0.3-tem in this shell.
退出项目时,可以清除环境配置
1 2
$ sdk env clear Restored java version to 21.0.3-tem (default)