Plain java compile issue with JDK1.7 #1429

Closed
sadin999 opened this Issue Jan 27, 2014 · 2 comments

Comments

2 participants

When attempting to run "lein compile" on the "storm-starter" repo from: https://github.com/nathanmarz/storm-starter, leiningen comes back with:

➜  storm-starter git:(master) ✗ lein compile
Java compiler not found; Be sure to use java from a JDK
rather than a JRE by modifying PATH or setting JAVA_CMD.

I have checked notes on previous issues and all the environment variables and JDK are seemingly installed properly and compile the clojure classes fine if the :java-source-paths is removed - from the same repo.

Relevant details are:

➜  storm-starter git:(master) ✗ lein version
Leiningen 2.3.4 on Java 1.7.0_51 Java HotSpot(TM) 64-Bit Server VM

➜  storm-starter git:(master) ✗ lein compile
Java compiler not found; Be sure to use java from a JDK
rather than a JRE by modifying PATH or setting JAVA_CMD.

➜  storm-starter git:(master) ✗ echo $JAVA_CMD
/usr/bin/java

➜  storm-starter git:(master) ✗ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

➜  storm-starter git:(master) ✗ ls -l $JAVA_HOME/lib/tools.jar
-rw-rw-r--  1 root  wheel  15254176 19 Dec 14:13 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar

➜  storm-starter git:(master) ✗ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

➜  storm-starter git:(master) ✗ javac -version
javac 1.7.0_51

➜  storm-starter git:(master) ✗ cat project.clj
(defproject storm-starter "0.0.1-SNAPSHOT"
  :source-paths ["src/clj"]
  :java-source-paths ["src/jvm"]

...

➜  storm-starter git:(master) ✗ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: OS X 10.9.1 (13B42)
      Kernel Version: Darwin 13.0.0

However despite all being seemingly right, getSystemJavaCompiler returns nil:

> (javax.tools.ToolProvider/getSystemJavaCompiler)
nil

Any hints?

Collaborator

hypirion commented Jan 27, 2014

Hey @drb999. The java version output shows me that /usr/bin/java/java is running a JRE (Java(TM) SE **Runtime Environment** (build 1.7.0_51-b13)) version, so the likely issue is that the JRE version is preferred over the JDK version when you're calling java.

As far as I can gather, there are a couple of possible solutions (I myself am using Linux, so these may not be 100% accurate):

  • Uninstall the JRE, if you don't need it.

  • Use jenv to setup the java environment.

  • In your .zshrc file, insert the following line

    export JAVA_CMD='/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java'

    (I am not sure if this turns out messy if you upgrade at some point)

  • Manually change the symlink /usr/bin/java to point to /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java
    (possibly same problem as previous point)

/Library/Java/Extensions

contained a stale version of tools.jar that was getting matched inappropriately by the compiler.

Removing the directory fixed the issue.

@sadin999 sadin999 closed this Jan 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment