Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDK 9 + Mac OS + jlink?

I installed the release version of JDK 9 on Mac OS.

jshell works great, Jigsaw module support works, but there is no jlink:

➜  java --version
java 9
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

This comes up empty:

find /System/Library/Frameworks/JavaVM.framework/Versions/Current/ -iname jlink\*

FYI:

➜  ls -l $(which java)
lrwxr-xr-x  1 root  wheel  74 Nov  7  2016 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
like image 882
clay Avatar asked Sep 25 '17 18:09

clay


People also ask

What is Java Jlink?

Jlink is a Java command line tool that is used to generate a custom Java runtime environment (JRE). You can use your customized JRE to run Java applications. Using jlink, you can create a custom runtime environment that only includes the relevant class file.

Which syntax is correct for creating a runtime image Jlink?

To create a runtime image with jlink you need to specify the root modules with --add-modules - starting with these modules, jlink will build a module graph and include all resolved modules in the new image. You have used --add-modules com. spacey.

Does Jre work on Mac?

Many Adobe applications depend on the Oracle Java Runtime Environment (JRE) for some features to work. Apple recently changed the way it includes Java in Mac OS, and with Lion, Java is no longer preinstalled. It is now an optional install that you must select.


2 Answers

You can verify your JAVA_HOME using which java and make sure it points to the default installation path which ideally should be

/Library/Java/JavaVirtualMachines...

[for e.g. I use it as export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/] and further you can find the jlink in the bin folder of Contents

find /Library/Java/JavaVirtualMachines/jdk-9.jdk -iname jlink\* 

which should return

/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin

Attaching a screenshot for reference of the location its installed:-

enter image description here

Note: Though in the screenshot, the command doesn't run successfully but its recognized.

like image 152
Naman Avatar answered Nov 06 '22 12:11

Naman


To add the JDK 9 tools to your path, add the following to the file .bashrc of your home directory:

export JAVA_HOME=$(/usr/libexec/java_home -v 9)
export PATH="$JAVA_HOME/bin:$PATH"

Did you notice the -v 9? you can change that to 1.8 if you ever want to switch back to JDK 1.8. For any newbie who can’t locate .bashrc in the Finder: press ⌘⇧. (command shift dot) to reveal hidden files.

like image 29
Jano Avatar answered Nov 06 '22 11:11

Jano