AquaEmacs and JDEE and Method Completion - Cannot find JDK's tools jar file (or equivalent)

2010-11-24 Software-Engineering Nerdy Tips & Tricks

Hhhmmm … nerd alert: If you do not like AquaEmacs, JDEE and Method Completion … don’t read this :).

Otherwise … good news: Not sure, if you have stumbled over this, but if you try to make your method completion work you might get an error message along the lines of …

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

… when you hit C-c C-v . to complete a method name. The problem is that the beanshell cannot find tools.jar (or more specifically classes.jar (on MacOS)).

In my case my jde-get-jdk-dir returns …

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

… but if you look the error message up in …

~/Library/Application Support/Aquamacs Emacs/jdee-2.4.0.1/lisp/jde.el

… you will see that on the darwin platform (MacOS) it tries to find the classes.jar file (which contains the tools stuff on darwin) in Classes/classes.jar, but the correct location is ../Classes/classes.jar, means to make it work you have to change jde-get-tools-jar() in jde.el to …

(defun jde-get-tools-jar ()

“Gets the correct tools.jar or equivalent. Signals an

error if it cannot find the jar.”

(let ((tools

(expand-file-name

(if (eq system-type ‘darwin)

"**../**Classes/classes.jar"

“lib/tools.jar”)

(jde-get-jdk-dir))))

(if (file-exists-p tools)

tools

(error (concat “Cannot find JDK’s tools jar file (or equivalent).”

“Type M-x describe-function [RET] jde-get-jdk-dir for more info.”)))))

… and then byte-compile it (just go to the Emacs-Lisp menu and select “Byte-compile this File”). Last but not least, you need to restart AquaEmacs and you are done.

OK. I admit it … this is nerdy :).