Open bingoohuang opened 4 years ago
java6上没有Y选项:
$ docker run -it --rm --name java6 -v /Users/bingoobjca/java6:/tmp/java6 enoniccloud/java6 bash
root@1c5cea1e68df:/# cd /tmp/java6
root@1c5cea1e68df:/tmp/java6# javac MyClass.java && java MyClass
JavaVersion: 1.6.0_45
2019-12-31 to yyyy-MM-dd: 2019-12-31
Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'Y'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:768)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:575)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:500)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:475)
at MyClass.main(MyClass.java:17)
java7开始支持Y选项:
$ docker run -it --rm --name java7 -v /Users/bingoobjca/java6:/tmp/java6 williamyeh/java7 bash
Unable to find image 'williamyeh/java7:latest' locally
latest: Pulling from williamyeh/java7
10a267c67f42: Pull complete
4342730f783a: Pull complete
Digest: sha256:3da95517af037e215204a05608a0d693eda57c46f9494b6e5432768393395f04
Status: Downloaded newer image for williamyeh/java7:latest
root@1804f728999e:/# cd /tmp/java6
root@1804f728999e:/tmp/java6# javac MyClass.java && java MyClass
JavaVersion: 1.7.0_80
2019-12-31 to yyyy-MM-dd: 2019-12-31
2019-12-31 to YYYY-MM-dd: 2020-12-31
本地管理多个java版本 Manage multiple Java SDKs with SDKMAN! with ease
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk list java
================================================================================
Available Java Versions
================================================================================
Vendor | Use | Version | Dist | Status | Identifier
--------------------------------------------------------------------------------
AdoptOpenJDK | | 13.0.1.j9 | adpt | | 13.0.1.j9-adpt
| | 13.0.1.hs | adpt | | 13.0.1.hs-adpt
GraalVM | | 19.3.0.r11 | grl | | 19.3.0.r11-grl
| | 19.3.0.r8 | grl | | 19.3.0.r8-grl
| | 19.3.0.2.r11 | grl | | 19.3.0.2.r11-grl
Java.net | | 15.ea.2 | open | | 15.ea.2-open
| | 14.ea.28 | open | | 14.ea.28-open
| >>> | 13.0.1 | open | installed | 13.0.1-open
| | 12.0.2 | open | installed | 12.0.2-open
| | 11.0.2 | open | | 11.0.2-open
| | 10.0.2 | open | | 10.0.2-open
| | 9.0.4 | open | | 9.0.4-open
================================================================================
Use the Identifier for installation:
$ sdk install java 11.0.3.hs-adpt
================================================================================
$ java -version
openjdk version "13.0.1" 2019-10-15
OpenJDK Runtime Environment (build 13.0.1+9)
OpenJDK 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)
$ ls -al ~/.sdkman/candidates/java/
drwxr-xr-x 9 rafal.borowiec staff 288 Jan 4 00:33 12.0.2-open
drwxr-xr-x 9 rafal.borowiec staff 288 Oct 6 14:05 13.0.1-open
lrwxr-xr-x 1 rafal.borowiec staff 57 Jan 4 00:20 current -> /Users/rafal.borowiec/.sdkman/candidates/java/13.0.1-open
$ sdk default java 12.0.2-open
Default java version set to 12.0.2-open
$ java -version
openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
$ ls -al ~/.sdkman/candidates/java/
drwxr-xr-x 9 rafal.borowiec staff 288 Jan 4 00:33 12.0.2-open
drwxr-xr-x 9 rafal.borowiec staff 288 Oct 6 14:05 13.0.1-open
lrwxr-xr-x 1 rafal.borowiec staff 57 Jan 5 11:49 current -> /Users/rafal.borowiec/.sdkman/candidates/java/12.0.2-open
$ sdk install maven
$ sdk install gradle
$ sdk list springboot
$ spring init --build=gradle --java-version=12 --dependencies=web --packaging=jar my-app.zip
Using service at https://start.spring.io
Content saved to 'my-app.zip'
在线版本