JDEE cannot find JDK's tools jar file on OS X

1.8k Views Asked by At

I am trying to configure JDEE for emacs 24 on OS X. When I create a .java file, the environment seems to be loaded automatically (please see picture), so it seems to be installed correctly. However, when I try to auto complete anything using M-x jde-complete (I haven't bound this to any keys yet) I get the following message:

Cannot find JDK's tools jar file (or equivalent).Type M-x describe-function [RET] jde-get-jdk-dir for more info.

I ran /usr/libexec/java_home to find my Java home and set this in my ~/.bash_profile:

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home"

I then configured JDEE to point on JDK in ~/.emacs:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(jde-jdk (quote ("1.7.0_17")))
 '(jde-jdk-registry (quote (("1.7.0_17" . "/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home")))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

Can anyone tell me why auto completion is not working? I believe that no parts of my JDEE i setup is currently working, however, I use auto completion to test as this is my main prority to get working.

Update: If I use M-x jde-compile it says

The JDE does not recognize JDK 1.7 javac. Assume JDK 1.6 javac?(yes or no)

It seems that it finds my JDK. If I type yes it will give the same error (Cannot find JDK's tools jar file (or equivalent).

enter image description here

3

There are 3 best solutions below

0
simonbs On BEST ANSWER

I followed this guide and now it works. I think they key was to add two JDKs and then select the one you wish to use. It seems like JDEE may not work with only one JDK added. However, now I get the error "Can not put GUI menu on this terminal" but I guess that's another question.

0
Alex Ott On

You can take fresh CEDET and setup it as described in this guide. Since november/december 2012, CEDET improved support for Java, including names completion, including automatic detection of JDK (tested on Linux and Mac OS X), plus has basic EDE projects for maven and ant (for Maven, EDE can extract list of dependencies, and use them to build name completion).

Here is example of name completion for Maven project:

enter image description here

1
user62271 On

For JDK 1.7 on Mavericks, Aquamacs 2.5, JDE 2.4.0.1

JDE is looking for "Classes/classes.jar" under JAVA_HOME (when it tries to locate the darwin equivalent for "lib/tools.jar").

You can help it by creating an alias like this:

sudo mkdir /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/Classes
sudo ln -sfv /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/lib/tools.jar /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/Classes/classes.jar

Relaunch emacs, and completion should work

There is a newer JDE 2.4.1 that I have not tried