halcyon / asdf-java

A Java plugin for asdf-vm.
MIT License
455 stars 86 forks source link

A way to install a JDK from a directory #95

Open dkowis opened 4 years ago

dkowis commented 4 years ago

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 commented 4 years ago

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.

augustobmoura commented 3 years ago

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

delgurth commented 3 years ago

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)
bric3 commented 3 years ago

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