sdkman installed grails 4.0.4, now grails is broken and wont start - macos

I have some older version of grails installed (3.3.8), and tried to use sdkman to install a newer version (4.0.4). The install worked, but grails is now completely broken. i also updated java to 14 from the dmg from the oracle website. Basically grails is now completely broken. Any ideas how to fix?
mac 10.14.4
$ sdk version
SDKMAN 5.7.3+337
$ sdk current java
Not using any version of java
$ java -version
java version "14.0.2" 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
$ sdk current
Using:
groovy: 2.5.8
$ grails --version
| Grails Version: 3.3.8
| Groovy Version: 2.4.15
| JVM Version: 14.0.2
$ sdk install grails
Downloading: grails 4.0.4
In progress...
######################################################################## 100.0%
Installing: grails 4.0.4
Done installing!
Setting grails 4.0.4 as default.
$ sdk current
Using:
groovy: 2.5.8
$ grails --version
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:107)
at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95)
at org.codehaus.groovy.reflection.ReflectionCache.<clinit>(ReflectionCache.java:39)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:209)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:107)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
at org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod.<clinit>(NumberNumberMetaMethod.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:124)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:346)
at java.base/java.lang.Class.newInstance(Class.java:604)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.createMetaMethodFromClass(MetaClassRegistryImpl.java:257)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:110)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
I dont see an easy way to uninstall java 14, or go back in time.
echo $PATH
/Users/xx/.sdkman/candidates/groovy/current/bin:/Users/xx/.sdkman/candidates/grails/current/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Appz/apache-jmeter-5.3/bin:/usr/local/go/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/xx/go/bin:/Users/xx/dev/grails-3.3.8/bin:/Users/xx/dev/flutter/bin:/Users/xx/dev/gradle-5.1.1/bin:/appz/cassandra/bin
I am guessing I can try to hack the path etc, to fix.
This is my current .bash_profile:
vi .bash_profile
export JAVA_HOME=`/usr/libexec/java_home`
export GRAILS_HOME=/Users/xx/dev/grails-3.3.8
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
export PATH=$PATH:$GRAILS_HOME/bin
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
export GRADLE_HOME=/Users/xx/dev/gradle-5.1.1
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
PATH="${PATH}:/Users/xx/dev/flutter/bin"
PATH=$PATH:$GRADLE_HOME/bin
# Cassandra
if [ -d "/appz/cassandra" ]; then
export PATH="$PATH:/appz/cassandra/bin"
fi
export PATH
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/simonh/.sdkman"
[[ -s "/Users/xx/.sdkman/xx/sdkman-init.sh" ]] && source "/Users/xx/.sdkman/bin/sdkman-init.sh"
~
This is odd, why is grails home still 3.3.8, when sdkman installed and made 4.0.4 current? Why didnt it edit the path? What version should I set gradle to? How do I go back to java 8, as I think there are bugs in java 14 which is causing issues with grails?

OK, figured it out.
First, I had to manually fix the java version.
To do this go to
$ /usr/libexec
$ ./java_home -V
This outputs one or more versions:
14.0.2, x86_64: "Java SE 14.0.2" /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
1.8.0_131, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
Now edit our .bash_profile and replace the JAVA_HOME line with the version you want, either the whole thing (1.8.0_131) or just the major (1.8) thusly:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Now when you open a new window, and do "java -version" you get 1.8, and when you do "grails -version" I finally get 4.0.4.
Yay!
The strange part is that just changing JAVA_HOME should not affect whats on the path, but it seems to. i.e. just setting JAVA_HOME should not affect what version of java is run when I type in "java", but it does. i.e. there is no line suchy as "PATH=$PATH:$JAVA_HOME/bin in muy bash_profile.

Related

How to downgrade JDK/javac - MacOS

I am trying to downgrade the jdk for a project I'm running from 17.0.5 to 1.8, but have not been able to replicate any of the results I've found online. Specs and attempts below.
Specs:
MacOS Big Sur v11.6.8
Java v1.8.0_351
Javac v17.0.5
Gradle v7.6
Homebrew v3.6.16
Running /usr/libexec/java_home -V:
Matching Java Virtual Machines (4):
17.0.5 (x86_64) "Oracle Corporation" - "Java SE 17.0.5" /Library/Java/JavaVirtualMachines/jdk-17.0.5.jdk/Contents/Home
1.8.351.10 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_351 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home
1.8.0_341 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home
First, I tried replicating the code from this answer regarding downgrading java:
https://stackoverflow.com/a/48422257/20834861
I quickly realized that the bash profile from sudo nano was already used to downgrade java to v1.8.
Then, I tried this solution: https://stackoverflow.com/a/23819062/20834861
But sudo mv jdk1.8.0_351.jdk ~/Desktop/ returns the following error: mv: rename jdk1.8.0_351.jdk to /Users/sahil/Desktop/jdk1.8.0_351.jdk: No such file or directory
So next, I tried the solution from this link:
https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/#java-home-and-macos-11-big-sur
When I tried the final line of code, echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home , I received the following error: zsh: permission denied: /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home .
Finally, I tried a similar line of code but with source as the bash_file instead of zshenv. I got the same error.
I must be missing something really obvious but I could not find anything else on the internet. Any help is appreciated.
With OSX you can select which jdk to use by using the JAVA_HOME environment variable. To set it.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home
That should work because it is in the list of jdk's you have available according to java_home. You can also use the java_home command to get the appropriate jdk.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Then when you run java or javac it should be from the version selected.

Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'

Trying to deploy my app to heroku, but it keeps failing with the error:
Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'
I have my JAVA_HOME,JAVA_PATH,and so on.. set up, i have an image of all of them here, i think they are correct. If i check java -version, and javac -version, they both show java 11.
I also tried putting to the root folder a system.properties.txt file and also instead of .txt a .gradle file with java.runtime.version=11 inside it.
Also i have this in my build.gradle:
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
But it keeps installing jdk8 at the start of the deploy(git push heroku master) like this:
Gradle app detected
remote: -----> Spring Boot detected
remote: -----> Installing JDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x test
remote: Downloading https://services.gradle.org/distributions/gradle-5.4.1-all.zip
here are the Images of the deploy failing and the environmental variables that are set up.
I have been with this problem for a week now, i think i tried all, but i would be really greatful if someone could help me with this. Thank you!
I had the same problem getting a "Java SE 11 using tool chain JDK 8" error. After Googling the problem, I was hinted toward the JAVA_HOME settings.
I use sdkman to manage my Java and Kotlin versions current version settings so after checking the current Java version configured in sdkman, I realized it was pointing to the GraalVM version 19 which targets Java 8.
So I simply reinstated the current JAVA_HOME to 11 with "sdkman use java 11.0.1-zulu" and everything was working fine.
Softjake
Add a system.properties file to your project with this line of code.
java.runtime.version=11
It sounds like you already solved your problem by renaming system.properties.txt to system.properties. (By the way, it's okay to answer your own question!)
In case it's helpful for anyone else, this is the official documentation from Heroku:
Create a system.properties file if one does not already exist, specify the version, and commit it to git. Supported version are described in the Java Support article. The file’s contents should look something like this:
java.runtime.version=11
https://devcenter.heroku.com/articles/customizing-the-jdk#specify-a-jdk-version
I had the same problem using openjdk 11 in linux Ubuntu.
But it worked ok in my work laptop. Same OS Ubuntu 18.04 LTS.
I checked version of jdk in my laptop it was:
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
but it inside is using tool chain: 'JDK 10 (1.10)'
so I got this message
using tool chain: 'JDK 10 (1.10)'
I check my work laptop and it has
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)
Searching about openjdk I discovered this site
https://adoptopenjdk.net
where I could get OpenJDK 11 (LTS) build 11.0.4+11
After I added it to alternatives
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-11.0.4+11/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-11.0.4+11/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javadoc" "javadoc" "/usr/lib/jvm/jdk-11.0.4+11/bin/javadoc" 1
and then choose everyone of them
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javadoc
After problem was solved.
I hope this can help someone else.
I don't know why but heroku doesnt't detect provided by gradle version
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Once I changed it to plain string JDK 11 was detected
sourceCompatibility = '11'
targetCompatibility = '11'
result:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/jvm
remote: -----> heroku-deploy app detected
remote: -----> Installing JDK 11... done
remote: -----> Discovering process types
remote: Procfile declares types -> web

DatabaseError: DPI-1047

I’m having an issue with instantclient. I was following the exact instructions in the http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html#ic_osx_inst to install Instant Client 11.2 on macOS.
However, when starting the server in the command line it return the following error:
DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "dlopen(libclntsh.dylib,
What is your version of Python? Is it 32-bit or 64-bit?
64-bit
What is your cx_Oracle version?
The latest version as of today, I believe it's 6.4.1
What exact command caused the problem (e.g. what command did you try to install with)?
When executing this command ‘python manage.py’ to run the application
What error(s) you are seeing?
DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos
In my bash profile I have these established:
export PATH="/usr/local/mysql/bin:$PATH"
export PATH=/usr/local/sbin:/usr/local/bin:$PATH
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc
export WORKON_HOME=$HOME/Virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
export VIRTUALENVWRAPPER_PYTHON=/usr/local/Cellar/python#2/2.7.15_1/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV=usr/local/Cellar/python#2/2.7.15_1/bin/virtualenv
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
export TNS_ADMIN=/usr/local/oracle/instantclient_11_2
source /usr/local/bin/virtualenvwrapper.sh
export PATH="/usr/local/opt/gettext/bin:$PATH"
if [ -f $(brew --prefix)/etc/bash_completion ]; then
source $(brew --prefix)/etc/bash_completion
fi
export PATH=~/instantclient_11_2:$PATH
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
Review the installation notes for cx_Oracle: https://cx-oracle.readthedocs.io/en/latest/installation.html#installing-cx-oracle-on-macos. Note especially the first sentence -- you cannot use the OS installation of Python!
If anyone is still getting the error DPI-1047 in Python, you might want to upgrade cx_Oracle. The latest major version (which supersedes cx_Oracle 8.3) has a new name python-oracledb. By default this new version doesn't need Oracle Client libraries. Check the installation documentation.

maven error when running in cygwin?

I have cygwin in Windows 7 and downloaded and installed maven "binaries" and have the following set
export JAVA_HOME=/cygdrive/c/java/jdk1.7.0_11
export MAVEN_HOME=/usr/apache-maven-3.0.5
export M2_HOME=/home/MyUser/.m2
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
$ which java
/cygdrive/c/java/jdk1.7.0_11/bin/java
$ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
$ which mvn
/usr/apache-maven-3.0.5/bin/mvn
$ mvn -version
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
I've looked at Maven error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher but it did not address my issue.
What did I miss?
Maven with Cygwin - Error: JAVA_HOME is not defined correctly
The "alias mvn=mvn.bat" answer toward the bottom of above post worked for me. However, is this THE solution?
I spent a couple of hours fruitlessly fiddling with different combinations of JAVA_HOME, M2_HOME and M2 after this same problem. Finally I set down to debugging the mvn script (by changing line 1 to read "#!/bin/sh -x"). It occurs because the script is relying on shell globbing to get the correct version of the .jar file (at approx. line 157):
CLASSPATH="${M2_HOME}/boot/plexus-classworlds-*.jar"
the * is not being expanded, for some reason globbing is disabled;
Hence the command the script attempts to execute is:
'/cygdrive/c/Program Files/Java/jdk1.7.0_40/bin/java' -classpath 'D:\apps\apache-maven-3.0.4\boot\plexus-classworlds-*.jar' '-Dclassworlds.conf=D:\apps\apache-maven-3.0.4\bin\m2.conf' '-Dmaven.home=D:\apps\apache-maven-3.0.4' org.codehaus.plexus.classworlds.launcher.Launcher -version
when it should be:
'/cygdrive/c/Program Files/Java/jdk1.7.0_40/bin/java' -classpath 'D:\apps\apache-maven-3.0.4\boot\plexus-classworlds-2.4.jar' '-Dclassworlds.conf=D:\apps\apache-maven-3.0.4\bin\m2.conf' '-Dmaven.home=D:\apps\apache-maven-3.0.4' org.codehaus.plexus.classworlds.launcher.Launcher -version
Solution: Edit the "mvn" script and change line 157 to read:
CLASSPATH="$(echo ${M2_HOME}/boot/plexus-classworlds-*.jar)"
change the JAVA_HOME path in .bashrc_profile file

How to change maven java home [duplicate]

This question already has answers here:
How to set specific Java version to Maven?
(28 answers)
Closed 1 year ago.
I want to change maven java home which is open jdk with sun jdk. How can I do it ?
root#ak-EasyNote-TM98:~# mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
Default locale: tr_TR, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-34-generic", arch: "amd64", family: "unix"
Edit:
So sorry. I forgot to write the below code :
root#ak-EasyNote-TM98:~$ java -version
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
My java home default path is sun jdk already. But maven java home has pointed openjdk. I want to fix it only for maven.
If you are in Linux, set JAVA_HOME using syntax export JAVA_HOME=<path-to-java>. Actually it is not only for Maven.
I am using Mac and none of the answers above helped me. I found out that maven loads its own JAVA_HOME from the path specified in: ~/.mavenrc
I changed the content of the file to be: JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
For Linux it will look something like:
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
The best way to force a specific JVM for MAVEN is to create a system wide file loaded by the mvn script.
This file is /etc/mavenrc and it must declare a JAVA_HOME environment variable pointing to your specific JVM.
Example:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
If the file exists, it's loaded.
Here is an extract of the mvn script in order to understand :
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
Alternately, the same content can be written in ~/.mavenrc
If you are dealing with multiple projects needing different Java versions to build, there is no need to set a new JAVA_HOME environment variable value for each build. Instead execute Maven like:
JAVA_HOME=/path/to/your/jdk mvn clean install
It will build using the specified JDK, but it won't change your environment variable.
Demo:
$ mvn -v
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.6, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-72-generic", arch: "amd64", family: "unix"
$ JAVA_HOME=/opt/jdk1.8.0_201 mvn -v
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: /opt/jdk1.8.0_201/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-72-generic", arch: "amd64", family: "unix"
$ export | grep JAVA_HOME
declare -x JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
Great helps above, but if you having the similar environment like I did, this is how I get it to work.
having a few jdk running, openjdk, oracle jdk and a few versions.
install apache-maven via yum, package is apache-maven-3.2.1-1.el6.noarch
Edit this file /etc/profile.d/apache-maven.sh, such as the following, note that it will affect the whole system.
$ cat /etc/profile.d/apache-maven.sh
MAVEN_HOME=/usr/share/apache-maven
M2_HOME=$MAVEN_HOME
PATH=$MAVEN_HOME/bin:$PATH
# change below to the jdk you want mvn to reference.
JAVA_HOME=/usr/java/jdk1.7.0_40/
export MAVEN_HOME
export M2_HOME
export PATH
export JAVA_HOME
Even if you install the Oracle JDK, your $JAVA_HOME variable should refer to the path of the JRE that is inside the JDK root. You can refer to my other answer to a similar question for more details.
Appears to be a duplicate of https://askubuntu.com/questions/21131/how-to-correctly-remove-openjdk-and-jre-and-set-the-system-use-only-and-only-sun#answer-21137 assuming that you are using Ubuntu.
The key is to use the command sudo update-java-alternatives -s java-6-sun. Any commands that rely on javac will be affected and not just Maven.
Just set JAVA_HOME env property.
I have two Java versions on my Ubuntu server 14.04: java 1.7 and java 1.8.
I have a project that I need to build using java 1.8.
If I check my Java version using java -version
I get
java version "1.8.0_144"
But when I did mvn -version I get:
Java version: 1.7.0_79, vendor: Oracle Corporation
To set the mvn version to java8
I do this:
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/
Then when I do mvn -version I get:
Java version: 1.8.0_144, vendor: Oracle Corporation

Resources