0

I installed Maven via Homebrew:

brew install maven

everything went ok, but when I ask for Maven version, there is a notice that Maven uses older version of Java:

macbook:~ jirka$ mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
Maven home: /usr/local/Cellar/maven/3.1.1/libexec
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: cs_CZ, platform encoding: MacCentralEurope
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"

but I use Java 7 for developing and version 7 is used in all system:

macbook:~ jirka$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
macbook:~ jirka$ 

I would like to ask you, is this a problem that a Maven uses later version of Java? Is there some consequences between Java version used by Maven and fact that applications are written for Java 7?

EDIT - my system setting:

macbook:~ jirka$ env
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/tx/c11w5sf11zj6qbfh5skp8kx00000gn/T/
Apple_PubSub_Socket_Render=/tmp/launch-85UUQ1/Render
TERM_PROGRAM_VERSION=326
TERM_SESSION_ID=AA674B2A-E20C-4B7F-BCD3-8DE637363A00
USER=jirka
SSH_AUTH_SOCK=/tmp/launch-XIC65i/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:29:56
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin
__CHECKFIX1436934=1
PWD=/Users/jirka
LANG=cs_CZ.UTF-8
SHLVL=1
HOME=/Users/jirka
LOGNAME=jirka
_=/usr/bin/env
macbook:~ jirka$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin
macbook:~ jirka$ echo $JAVA_HOME

macbook:~ jirka$
user2148736
  • 1,283
  • 4
  • 24
  • 39

3 Answers3

1

Well as far as I can tell from my experience you might encounter some problems with Java 7 for development and with Java 6 for Maven. For example you can use some specific features of Java 7 (like try-with-resources statement) which are not supported in Java 6.

Try entering in your console:

echo $PATH

echo $JAVA_HOME

$PATH is probably pointing to Java 7, while $JAVA_HOME is pointing to Java 6. If it's your case - edit your $JAVA_HOME and make it point to your Java 7 installation.

Ernestas Kardzys
  • 1,719
  • 2
  • 16
  • 21
  • It's weird, because JAVA_HOME variable refers to nowhere, probably Java installation of Java isn't correct? See my previous question. – user2148736 Nov 12 '13 at 13:34
  • Try setting your JAVA_HOME to Java 7 with export command: http://stackoverflow.com/questions/1348842/what-should-i-set-java-home-to-on-osx – Ernestas Kardzys Nov 12 '13 at 13:36
1

Try to fix your development environment with jenv.

jEnv is a command line tool to help you forget how to set the JAVA_HOME environment variable

brew install https://raw.github.com/gcuisinier/jenv/homebrew/jenv.rb

jenv add /Library/Java/JavaVirtualMachines/jdk17011.jdk/Contents/Home oracle64-1.7.0.11 added

jenv global oracle64-1.7.0.11
MariuszS
  • 30,646
  • 12
  • 114
  • 155
0

There is a need to set JAVA_HOME system variable via export command:

macbook:~ jirka$ cat '.bash_profile' 
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
user2148736
  • 1,283
  • 4
  • 24
  • 39