[JAVA] Use SDKMAN! With Git Bash

TL;DR

When using Git Bash (MINGW64) or MSYS2 that comes with Git for Windows, use SDKMAN! By adding the following to .bashrc etc. Will be possible.

.bashrc


export MSYS=winsymlinks:lnk

The installation itself is as follows, so it is omitted.

https://sdkman.io/install

Serpentine

Why did you try to use SDKMAN!

The JDK is being built and provided by various vendors and communities, so I'd like to make it easy to switch. (Do you think?)

If you want to do the above, you will need a version management tool such as the JDK. There is a tool called SDKMAN! In the JVM system, so use this.

Please refer to the following for the SDK that can be installed using SDKMAN! (Indicated because it is written. Various languages, tools, application frameworks, etc. can be installed).

Challenges when using SDKMAN! With Git Bash

Looking at the following, it seems that it can be used normally with Git Bash, but although I can download the JDK, I get an error when I try to set it to the default.

https://sdkman.io/install

$ sdk default java 8.0.202.hs-adpt
SDKMAN: No update needed. Using existing candidates cache: ant,asciidoctorj,bpipe,ceylon,crash,cuba,cxf,gaiden,glide,gradle,grails,groovy,groovyserv,infrastructor,java,jbake,kotlin,kscript,lazybones,leiningen,maven,micronaut,sbt,scala,spark,springboot,sshoogr,vertx,visualvm
Not refreshing version cache now...
Validate java 8.0.202.hs-adpt for MINGW64_NT-10.0: valid
Validation URL: https://api.sdkman.io/2/candidates/validate/java/8.0.202.hs-adpt/mingw64_nt-10.0
rm: cannot remove '/c/Users/tenten0213/.sdkman/candidates/java/current': Is a directory
ln: failed to create symbolic link '/c/Users/tenten0213/.sdkman/candidates/java/current/8.0.202.hs-adpt': File exists

↑ enables debug mode. (Set sdkman_debug_mode in ~ / .sdkman / etc / config to true)

Looking at the code, it seems that there is an error in the following rm -f.

https://github.com/sdkman/sdkman-cli/blob/b63ee15c8885b89ea09dee4f965fbd48167398d1/src/main/bash/sdkman-path-helpers.sh#L85

The reason for the error is that if you don't set it at the beginning, ln -s will not create a symbolic link, it will create a copy. It's a directory instead of a symbolic link, so rm -f will result in an error.

So, by returning to the beginning and setting MSYS = winsymlinks: lnk, symbolic links (Windows shortcuts) are created instead of copies, and they can be used safely.

reference

Recommended Posts

Use SDKMAN! With Git Bash
Use Git with SourceTree and Eclipse
Use ProGuard with Gradle
Use Puphpeteer with Docker
Use ngrok with Docker
Use webmock with Rspec
Use WebJars with Gradle
Use jlink with gradle
Use Lambda Layers with Java
Use GDAL with Python with Docker
Use docker's in-container shell with cygwin [docker exec -it bash]
Use pfx certificate with Okhttp3
Use multiple databases with Rails 6.0
Use Spring JDBC with Spring Boot
Use Ruby with Google Colab
Use SpatiaLite with Java / JDBC
Use log4j2 with YAML + Gradle
[Docker] Use whenever with Docker + Rails
Use PlantUML with Visual Studio Code
Use Basic Authentication with Spring Boot
Use java with MSYS and Cygwin
Use constructor with arguments in cucumber-picocontainer
Use PostgreSQL inet type with DbUnit
Why use orchestration tools with Docker
Use bootstrap 4 with PlayFramework 2.6 (no CDN)
Let's use Amazon Textract with Ruby
Use JDBC with Java and Scala.
Use Java 11 with Google Cloud Functions
How to use mssql-tools with alpine
Beginning with Spring Boot 0. Use Spring CLI
Use cuda11.0 with pytorch using Docker