When I'm calling mvn --version I get the following :
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /usr/local/Cellar/maven/3.8.2/libexec
Java version: 16.0.2, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: US-ASCII
OS name: "mac os x", version: "11.4", arch: "x86_64", family: "mac"
So I take the version 16 is used
But when I'm calling java -version :
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
Here I have java11.
I found out that the mvn command (found using which mvn) is actually a bash script in which the JAVA_HOME variable is defined, so I do get how I'm landing into /usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home when running maven.
But what is extremely confusing is the behaviour of java -version. java refers to an executable /usr/bin/java that is just lying there. And if I set the JAVA_HOME :
JAVA_HOME=/usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home
Then java -version returns :
openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment Homebrew (build 16.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 16.0.2+0, mixed mode, sharing)
So it looks like the /usr/bin/java executable reads this variable and calls the corresponding "real" java exec...
But then, my paramount question is : when the JAVA_HOME variable isn't defined, how the heck is this /usr/bin/java executable figuring where is the openjdk in version 11 ?
The short answer is on macos /usr/bin/java is the same executable as /usr/libexec/java_home. See the manual page for java_home(1) which references a "default order."
Related
I have two versions of Java in my mac and I am trying to switch from 1.8 to 1.7 for compiling one of my project which has 1.7 specific contents. Though I ran the following commands in the terminal:
$ alias setJdk1.7='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
$ setJdk1.7
With that, I can see the proper version in java -version and mvn -version.
$ java -version
java version "1.7.0_181"
Java(TM) SE Runtime Environment (build 1.7.0_181-b09)
Java HotSpot(TM) 64-Bit Server VM (build 24.181-b09, mixed mode)
$ mvn -version
Apache Maven 3.0.5 (...)
Maven home: *mvn path*
Java version: 1.7.0_181, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_181.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.5", arch: "x86_64", family: "mac"
However, the /usr/libexec/java_home still seems to be pointing to the 1.8 java only.
$ echo $(/usr/libexec/java_home)
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
I am very new to mac and not really sure how I can toggle between versions. This is not allowing to successfully compile my project.
Maybe try using a function instead and setting up your command as follows:
setJdk1.7() {
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
export PATH=$JAVA_HOME/bin:$PATH
}
Your command likely doesn't work because $JAVA_HOME is never added to your $PATH.
I am facing a weird issue in maven.
I am running java 1.8 in 64 bit windows .
When I run java -version I get the below message
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
I am running maven 3.3.9 on the above jdk.
When I run mvn -version I get the below message
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T19:41:4
7+03:00)
Maven home: D:\Users\57181\Projects\mvn\apache-maven-3.3.9-bin\apache-maven-3.3.
9
Java version: 1.8.0-ea, vendor: Oracle Corporation
Java home: D:\java\java8\java8\jdk1.8.0\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "dos"
However when I run mvn -d64 -version , I get below error
Error: This Java instance does not support a 64-bit JVM.
Please install the desired version.
I need to build a very large project using maven which needs 2 GB heap.
Though my machine has 8 GB RAM , I am not able to set the heap since Maven is running in 32 bit( In the task manager , the process shows as * 32 )
Has anybody faced this issue ?
Is there any configuration needed to run maven in 64 bit JVM ?
You are picking up the default JVM installed for web page plugins etc as it is in your PATH.
You can put the JDK directory first in your PATH environment variable which most likely is the simplest.
You may also choose to set the environment variable JAVA_HOME to point to the JDK you want to use, either as part of your environment or by modifying the mvn script.
I'm using Maven as a build tool for Scala code. I'm able to build the Scala objects fine using maven. However when I echo $M2_HOME ,$M2,$JAVA_HOME, everything is returning blank. While this is a sign that these environment variables are not set properly, they are not causing any issues, which to me sounded a bit surprising. Can you please let me know what I'm missing here. I'm running Ubuntu 15.04 and included the below output if needed.
~$java -version
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
~$mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_45-internal, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-58-generic", arch: "amd64",family: "unix"
This is the first time I'm using Java, Maven and Scala so kindly excuse my ignorance.
I am trying to package a java project using maven. I've done it before on my old computer, but I can't seem to make it work on my new computer.
Here is the error:
`
(env)kyle#thinkpad ~/Code/simplefilehosting $ mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_95, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-38-generic", arch: "amd64", family: "unix"
(env)kyle#thinkpad ~/Code/simplefilehosting $ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
(env)kyle#thinkpad ~/Code/simplefilehosting $ javac -version
javac 1.7.0_95
(env)kyle#thinkpad ~/Code/simplefilehosting $
Here is my version information for java, javac and mvn:
(env)kyle#thinkpad ~/Code/simplefilehosting $ mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_95, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-38-generic", arch: "amd64", family: "unix"
(env)kyle#thinkpad ~/Code/simplefilehosting $ java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
(env)kyle#thinkpad ~/Code/simplefilehosting $ javac -version
javac 1.7.0_95
(env)kyle#thinkpad ~/Code/simplefilehosting $
I tried looking at it online and add a plugin but then my mvn never realized the plugins tag or anything else. And I haven't changed the pom.xml from the last time I was able to package it.
Without the actual error message to diagnose (I think you intended to include it but didn't)...but a few things:
-check your M2_HOME and JAVA_HOME variables and make sure they are correct
-make sure settings.xml is in your ~/.m2 or $M2_HOME/config directories
-on your old machine, delete your entire ~/.m2/repository directory and see if it builds, if you upgraded Maven along the way there might be something you already have that Maven3 can't for some reason download
-consider upgrading, 3.0.5 was an intermediate version that was between the old Maven2 and Maven3 artifact resolution, some major differences, some completely different behavior, who knows what you have.
Why does everything around Java need to be so ____ complicated? I am trying to run applications - that run on other people's machines - and getting the error:
Obtained an unexpected kind of VM install: null
Has anyone seen anything like this?
Anypoint Studio is a product provided by Mulesoft and based on Eclipse.
Mac OS X Yosemite
$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
$ mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T07:57:37-04:00)
Maven home: /Users/jkalis/Maven/apache-maven-3.3.3
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"
You need to reference the version of the JRE that you want to use in the project properties.
Here are the steps to add it to your project.
Select the Project
Choose the Properties
Choose 'Java Build Path'
Click Libraries on the Dialog
Choose 'Add Library...'
Select 'JRE System Library'
Click Next
Choose the JRE System Library to use.
Click Finish