asdf-java icon indicating copy to clipboard operation
asdf-java copied to clipboard

A way to install a JDK from a directory

Open dkowis opened this issue 5 years ago • 4 comments

This is a bit tougher, but with jenv, I could install a JDK, and do something like jenv add /path/to/jdk and it would determine the major, minor and patch versions from the output of java -version in that directory.

It was really handy to be able to add a JDK, especially the ones from oracle. I'm not sure how this would work, but it'd be useful. Found myself missing this functionality yesterday.

dkowis avatar May 23 '20 15:05 dkowis

Wouldn't you have the same behaviour if you use the .tool-versions file in the directory you would like to use the desired Java SDK?

x80486 avatar Aug 08 '20 15:08 x80486

Well, only if the asdf java plugin knew where to find said java SDK. Right?

I'd have to have some way of adding it to the plugin first.

dkowis avatar Aug 08 '20 15:08 dkowis

You can symlink the custom jdk to the $ASDF_DIR/installs/java and reshim and it will work fine. Just ln -s {path_to_jdk} "$ASDF_DIR/installs/java/{custom_jdk_name}" and then asdf reshim java

augustobmoura avatar Nov 03 '20 13:11 augustobmoura

On MacOS make sure you include the /Contents/Home to the path, so for example:

ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home ~/.asdf/installs/java/oracle-1.7.0
asdf reshim java

This will make it possible to do:

asdf local java oracle-1.7.0
asdf which java

/Users/wessel/.asdf/installs/java/oracle-1.7.0/bin/java

java -version

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

delgurth avatar Apr 04 '21 11:04 delgurth

Hi just noticed (again) this issue,

For reference, here's a use case that might be useful. And if download was handled by asdf-java it would allow to skip the download step.

Here's the verbatim comment from #92:

Hi, just chiming in, currently I'm using specific JDK builds and I'm doing the following. This would be nice if the add a local version could be extended to adding a remote version too.

$ curl -sLO https://download.java.net/java/early_access/loom/4/openjdk-17-loom+4-174_osx-x64_bin.tar.gz
$ mkdir -p openjdk-17-loom+4-174; tar --strip-components=4 -C openjdk-17-loom+4-174/ -xf openjdk-17-loom+4-174_osx-x64_bin.tar.gz jdk-17.jdk/Contents/Home
$ asdf reshim java
$ curl -sLO https://download.java.net/java/early_access/lanai/3/openjdk-17-lanai+3-133_osx-x64_bin.tar.gz
$ mkdir -p openjdk-17-lanai+3-133; tar --strip-components=4 -C openjdk-17-lanai+3-133/ -xf openjdk-17-lanai+3-133_osx-x64_bin.tar.gz jdk-17.jdk/Contents/Home
$ asdf reshim java

bric3 avatar Apr 09 '21 11:04 bric3