JDE (Pete's notes)

JDE home page

Get extras needed by JDE

The Emacs JDE requires several extra pieces: elib, eieio, semantic and Speedbar. An up-to-date version of elib is already part of the standard XEmacs packages. Old versions of the others are in the XEmacs packages in /usr/lib/xemacs/xemacs-packages/lisp/, and they won't work with JDE, so you have to get eieio, semantic and Speedbar. We'll load the new versions into ~/.xemacs, and then set up the XEmacs load-path so that the new versions are found before the old.

Web to the CEDET home page. Download the "Sematic Bovinator", "eieio" and "Speedbar".

Install speedbar

(as siemsen)
cd ~/.xemacs
gunzip speedbar-0.14beta4.tar.gz
tar xf speedbar-0.14beta4.tar
rm speedbar-0.14beta4.tar
ln -s speedbar-0.14beta4 speedbar
cd speedbar
xemacs Makefile
EMACS=xemacs
LOADPATH=../speedbar
(exit)
make

This executed with several warnings.

Install eieio

(as siemsen)
cd ~/.xemacs
gunzip eieio-0.174.tar.gz
tar xf eieio-0.174.tar
rm eieio-0.174.tar
ln -s eieio-0.174 eieio
cd eieio
xemacs Makefile
EMACS=xemacs
LOADPATH=../../eieio
(exit)
make

This mostly runs, but complains about

While compiling toplevel forms in file /usr/src/eieio/linemark.el:
  !! Symbol's function definition is void ((overlay-p))
>>Error occurred processing linemark.el: 
Symbol's function definition is void: overlay-p
    

I emailed Eric Ludlam about it, and he responded

Hmmm, this looks like a strange issue with the aliases I create to handle overlay compatibility. It trigger's off of the xemacs feature. Semantic does the same thing which is what is surprising that it would fail here. In fact, the word "overlay-p" doesn't exist in my file. Perhaps you have loaded overlay.el which is supposed to be a compatibility layer for XEmacs emulating Emacs which can cause some problems.

Fortunately, if you aren't planning on explicitly using linemark, you can ignore this error.

Eric

Install semantic

(as siemsen)
cd ~/.xemacs
gunzip semantic-1.414.tar.gz
tar xf semantic-1.414.tar
rm semantic-1.414.tar
ln -s semantic-1.414 semantic
cd semantic
xemacs Makefile
EMACS=xemacs
(exit)
make

This executed with several warnings.

Get and install JDE

Web to the JDE home page and download the JDE into ~/.xemacs.

(as siemsen)
cd ~/.xemacs
gunzip jde-beta.tar.gz
tar xf jde-beta.tar
rm jde-beta.tar
ln -s jde-2.2.9 jde
chown -R siemsen:users jde-2.2.9
cd jde/lisp
xemacs makefile
EMACS = xemacs
ELIB = /usr/lib/xemacs/xemacs-packages/lisp/elib
(exit)
make

This unpacks the code and the docs. The local docs don't explain installation. I had to go to the docs on the JDE home page to find out the following.

Mozilla doesn't like "file" URLs, and the JDE docs contain frames that won't work unless the docs are installed in a web tree. So copy them into the web tree...

cd ~/.xemacs/jde/doc
tar cf - html | (cd /usr/web; tar xfp -)
mv /usr/web/html /usr/web/jde

Now you can use the following "local" versions, or the accompanying links to the JDEE website

It's best to get and print PDF versions of these manuals. To get the PDF versions, go to the JDE home page, then to the "Contributed Software" section.

We need to tell XEmacs where the JDE is, so it'll be loaded at startup. Edit my ~/.xemacs/init.el file and add the following if I'm on proteus:

(add-to-list 'load-path (expand-file-name "/home/siemsen/.xemacs/jde/lisp"))
(add-to-list 'load-path (expand-file-name "/home/siemsen/.xemacs/eieio"))
(add-to-list 'load-path (expand-file-name "/home/siemsen/.xemacs/speedbar"))
(add-to-list 'load-path (expand-file-name "/home/siemsen/.xemacs/semantic"))
(require 'jde)

There are many mistakes in the JDE User's Guide, including...

To be able to use TAGS on Java files, you have to have access to the jtags script that builds tags databases. Edit my .bashrc file and add this when I'm on gazelle:

pathadd ~/.xemacs/jde/lisp

Using JDE

If JDE is installed, XEmacs startup will be much slower, and when you edit a Java file, you'll notice "JAVA" and "JDE" menu items.

Customizing JDE

To customize the JDE, use JDE->Project->Options. Don't forget to Set and Save your changes. This will update the ~/.xemacs/custom.el file.

Project files

To work on a set of software files, you're supposed to establish a project file named prj.el in the directory that contains the .java files. Then you set up various jde- variables, and save them in the project file. Whenever you open a java file, the JDE will search for the project file and read it to set the variables.

To set per-project JDE variables, don't just edit the project file. Instead, set the variables and then tell XEmacs to update the project file so they'll be set correctly next time. To create a project file, use JDE->Project->Project File>Create New.

The documented way to set the project file variables is to use JDE->Project->Options mode to set the variables, and then save them to the project file. Trouble is, the "customize" mode sets variables in the ~/.xemacs/custom.el file, and they don't get written to the prj.el file at all. If you want the prj.el file to "work", I guess you have to edit it manually. Sigh.

You can also convert your Ant build.xml file into a JDEE prj.el file. See Converting build.xml to prj.xml

Using Ant with JDE

Set jde-ant-build as described above.

Using JDEbug

In general, the JDEbug User's Guide describes how to set up JDEbug, but it's slightly different for XEmacs. Ignore the stuff about "State" buttons when setting jde-db-debugger. When I was done, I had these new lines in my ~/.xemacs/custom.el:
'(jde-bug-vm-includes-jpda-p t)
'(jde-bug-jdk-directory "/usr/local/jdk1.3/")
'(jde-db-debugger (quote ("JDEbug" "" . "Executable")))
'(jde-db-source-directories (quote ("/home/siemsen/nandisc" "/home/yplay-java" "/home/opennnms-all/jsnmp")))
Exit XEmacs and restart, open a JAVA file, and you should see the JDEbug menu item at the top of the window.

JDE Cool Tricks

Use C-c C-v j to javadoc a class, method, or variable.

Use C-c C-v C-w to lookup the java doc for a class or symbol.

Use C-c C-v C-y to lookup the java source code for a class.

Use C-c C-v C-z to insert the "import" for a class.

Use C-c C-v . to auto-complete. Cycle through completions by hitting it multiple times.

Use M-x jde-import-kill-extra-imports to analyze your import statements and delete the ones that are unnecessary.

Use M-x jde-import-organize to group and sort a buffer's import statements according to rules that you specify.

Use M-x ispell-comments-and-strings to spell-check comments in source code.

"Abbrev Mode" in the JDE lets you type part of a Java keyword and the JDE creates the corresponding syntactic structure. For instance, you type "for " and the JDE prompts for the conditional clause and creates the full "for" block. This can be annoying, because it tends to complete things when you don't want it to, like when you're typing comments. You can avoid it by typing C-q before the space character, but that's asking too much. The jde-enable-abbrev-mode variable controls whether this is enabled. I wish it were like dynamic class completion, where you could type part of the word and then tell XEmacs to do the completion explicitly, with a special key. Sigh.


Pete Siemsen
Last modified: Tue Nov 15 15:29:06 MST 2005