1 <?xml version="1.0" encoding="utf-8"?>
3 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBk XML V4.4CR2//EN"
4 "file:///c:/home/xae-dev/xae/doctypes/docbook/docbookx.dtd" []>
7 <?xml-stylesheet href="file:///c:/home/jde-dev/jde/doc/src/styles/html/jdebook.xsl" type="text/xsl" ?>
11 <?xml-stylesheet href="file:///d|tpe-dev/tpe/styles/docbook/html/docbook.xsl" type="text/xsl" ?>
17 <title>JDEE User's Guide</title>
23 Revised for JDEE <productnumber>2.3.6</productnumber>
37 <holder>Paul Kinnucan</holder>
43 <title><anchor id="Intro"/>Introduction</title>
46 <para>Welcome to the <emphasis>JDEE User's Guide</emphasis>. This
47 guide explains how to use the JDEE to develop Java applications and
48 applets. The guide assumes that you are familiar with Emacs, the
49 Java programming language, and Java development tools provided
50 by Sun Microsystems, Inc.</para>
54 This guide and the JDEE user interface use the term "JDK" to
55 refer to Sun's Java 2 Software Development Kit (SDK) and its
62 <title><anchor id="AboutJDE"/>About the JDEE</title>
65 <para>The Java Development Environment for Emacs (JDEE) is an
66 Emacs Lisp package that interfaces Emacs to third-party Java
67 application development tools, such as those provided by Sun
68 Microsystems as part of its JDK. The result is an integrated
69 development environment (IDE) comparable in power to many
70 commercial Java IDEs. Features include: </para>
75 <para>source code editing with syntax highlighting and auto
79 <para>automatic completion of class fields and methods
83 <para>compilation with automatic jump from error messages
84 to responsible line in the source code.</para>
88 generates class and method skeletons automatically
92 <para>run Java application in an interactive (comint)
98 integrated debugging with interactive debug command
99 buffer and automatic display of current source file/line
100 when stepping through code
105 browse JDK doc, using the browser of your choice
110 browse your source code, using the Emacs etags facility
111 or a tree-structured speedbar.
115 supports latest version of JavaSoft's Java Development
119 runs on any platform supported by Emacs and Sun's Java SDK (e.g.,
120 Win95/NT and Solaris)
124 easily and infinitely customizable
128 works with FSF Emacs and XEmacs
138 <title><anchor id="JDERequirements"/>JDE Requirements</title>
141 <para>The JDE requires the following software: </para>
146 <para><ulink url="http://www.gnu.org/">FSF Emacs</ulink> or
147 <ulink url="http://www.xemacs.org/">XEmacs</ulink> on Unix
148 platforms; the 20.6.1 version (or later) of
149 <ulink url="ftp://ftp.gnu.org/gnu/windows/emacs/latest">NT/Emacs</ulink> on
150 Windows platforms, for general source file editing and tool integration functions.
154 <ulink url="http://java.sun.com/j2se">Java
155 Development Kit (JDK)</ulink> or compatible set of Java
156 development tools (compiler, virtual machine, debugger,
157 class libraries, etc.)
161 Web browser (e.g., Netscape or Internet Explorer) for
162 viewing documentation.
167 latest versions of Eric Ludlam's <symbol>speedbar</symbol>,
168 <symbol>semantic</symbol>, and
169 <symbol>eieio</symbol> packages available for download from
170 <ulink url="http://cedet.sourceforge.net">the CDET home page</ulink>
175 The elib package available from the
176 <ulink url="http://jdee.sunsite.dk">JDE web site</ulink>
182 <command>bash</command> or another Unix-style shell highly
183 recommended for Windows95/NT environments. The <ulink
184 url="http://sources.redhat.com/cygwin">cygwin</ulink>
185 Unix emulation package for Windows from Red Hat includes
186 <command>bash</command>.
196 <title><anchor id="JDEComponents"/>JDEE Components</title>
201 The JDEE distribution includes the following files:
209 <ulink url="../../../lisp/jde.el"><filename>jde.el</filename></ulink>.
210 Defines jde-mode, a major Emacs mode for developing Java code.
214 <ulink url="../../../lisp/jde-run.el"><filename>jde-run.el</filename></ulink>.
215 Runs Java applications and applets
219 <ulink url="../../../lisp/jde-db.el"><filename>jde-db.el</filename></ulink>.
220 Interfaces Emacs to <command>jdb</command>, the command-line debugger that
227 url="../../../lisp/jde-gen.el"><filename>jde-gen.el</filename></ulink>.
228 Contains code generation templates.
234 <filename>bsh.jar</filename>. Compiled files for the
235 <ulink url="http://www.beanshell.org/">BeanShell</ulink>,
236 a Java source code interpreter developed by Pat Neimeyer.
243 url="../../../lisp/beanshell.el"><filename>beanshell.el</filename></ulink>.
244 Provides an Emacs interface to the BeanShell interpreter.
251 url="../../../lisp/jde-wiz.el"><filename>jde-wiz.el</filename></ulink>.
252 Provides "wizards" that generate skeleton
253 implementations of interfaces and skeleton overrides of
254 methods declared by superclasses.
260 url="../../../lisp/jde-complete.el"><filename>jde-complete.el</filename></ulink>.
261 Automatic field and method completion package.
266 <ulink url="../../../lisp/jde-parse.el"><filename>jde-parse.el</filename></ulink>.
267 Java parser package.</para>
271 <ulink url="../../../lisp/java.bnf"><filename>java.bnf</filename></ulink>.
272 Java grammar used to generate the JDE's lisp-based Java parser.
276 <ulink url="../../../lisp/jde-bug.el"><filename>jde-bug.el
278 JDEbug user interface package.
282 <ulink url="../../../lisp/jde-dbs.el"><filename>jde-dbs.el</filename></ulink>.
283 JDEbug low-level command interface package.
287 <ulink url="../../../lisp/jde-dbo.el"><filename>jde-dbo.el</filename></ulink>.
288 JDEbug output processing functions.
293 source code, jar files, and documentation for the <ulink
294 url="../../java/">Java components</ulink> of the
300 url="../../../lisp/jtags"><filename>jtags</filename></ulink>
301 is a bash shell script that tags Java source hierarchies.
308 url="../../../lisp/jtags.csh"><filename>jtags.csh</filename></ulink>
309 is a c shell script that tags Java source heierarchies.
319 <title><anchor id="LatestVersion"/>Latest Version</title>
322 <para>See <ulink url="http://jdee.sunsite.dk/rootpage.html#Downloading">
323 Downloading the JDE</ulink> on the JDE website for instructions on
324 downloading the most recent version of the JDE.
331 <title><anchor id="InstallingJDE"/>Installing the JDE</title>
332 <para>See the <ulink url="http://jdee.sunsite.dk/install.html">
333 JDE Installation Guide</ulink> on the JDE website for information
334 on installing the JDE on your system.</para>
340 <title><anchor id="ContactingAuthor"/>Contacting the Author</title>
343 <para>Please send bug reports and enhancement suggestions to
344 <ulink url="mailto:pkinnucan@comcast.net">Paul Kinnucan</ulink>.
352 <title><anchor id="RegisterSelectJDK"/>Registering and Selecting a JDK</title>
354 <para>The JDEE relies on command-line Java development tools, such
355 as those supplied by Sun Microsystems as part of its Java 2
356 Software Development Kit (SDK) also known as a Java Development
357 Kit (JDK). Before you can use the JDEE to compile, debug, or run
358 an application, you must tell it where the Java compiler,
359 debugger, and virtual machine are located on your system. The
360 JDEE assumes that the compiler, debugger, and vm are named
361 <filename>javac</filename>, <filename>jdb</filename>, and
362 <filename>java</filename>, respectively, and that they are
363 located on your system's command path. If these tools are not
364 located on the system command path or have different names, you
365 must tell the JDEE where they are located. The JDEE provides
366 customization variables for specifying the locations of
371 However, if you are using one or more versions of Sun's JDK or a
372 clone of the Sun JDK, the easiest way to specify the location of
373 the external development tools is to register the version of the
374 JDK that you intend to use. It is especially advantageous to
375 register a JDK, if you intend to use multiple versions of the
376 JDK. The reason? Registering each version of the JDK allows you
377 to change JDKs by changing a single customization variable. The
378 following sections explain how to register and select
384 <title><anchor id="RegisterJDK"/>Registering a JDK</title>
386 <para>To register a version of the JDK with the JDEE:</para>
390 <para>Start Emacs.</para>
393 <para>Type <command>M-x customize-variable</command> and
394 press <command>Enter</command></para>
395 <para>Emacs prompts you to enter the name of a variable
399 <para>Enter <varname>jde-jdk-registry</varname> and
400 press <command>Enter</command>.</para>
401 <para>The <varname>jde-jdk-registry</varname> customization
402 buffer appears.</para>
406 <imagedata fileref="images/regjdk1.gif"/>
412 <para>Click the <command>INS</command> button.</para>
413 <para>The entry for the JDK appears.</para>
417 <imagedata fileref="images/regjdk2.gif"/>
423 <para>Enter the version number of the JDK and the path of the directory
424 in which the JDK is installed.</para>
427 <para>Repeat the preceding steps until you have entered the versions and
428 paths of all versions of the JDK that you wish to use with the JDEE.</para>
432 <imagedata fileref="images/regjdk3.gif"/>
438 <para>Click the <command>State</command> button.</para>
439 <para>The <command>State</command> menu appears.</para>
442 <para>Select <command>Save for Future Sessions</command> from
443 the <command>State</command> menu.</para>
445 <para>This saves the setting of <varname>jde-jdk-registry</varname>
446 in your <filename>.emacs</filename> file.</para>
450 <para>Click the <command>Finish</command> button to dismiss
451 the customization buffer.</para>
458 <title><anchor id="SelectingJDK"/>Selecting a JDK</title>
459 <para>To select a JDK:</para>
462 <para>Type <command>M-x customize-variable</command> and
463 press <command>Enter</command></para>
464 <para>Emacs prompts you to enter the name of a variable
468 <para>Enter <varname>jde-jdk</varname> and
469 press <command>Enter</command>.</para>
470 <para>The <varname>jde-jdk</varname> customization
471 buffer appears.</para>
475 <imagedata fileref="images/seljdk1.gif"/>
479 <para>The buffer lists the JDKs that you have previously registered
480 (see <ulink url="#RegisterJDK">Registering a JDK</ulink>).</para>
483 <para>Click the radio button next to the version of the JDK you
487 <para>Click the <command>State</command> button.</para>
488 <para>The <command>State</command> menu appears.</para>
491 <para>Select <command>Save for Future Sessions</command> from
492 the <command>State</command> menu.</para>
495 <para>Click the <command>Finish</command> button to dismiss
496 the customization buffer.</para>
500 <para>This procedure saves your JDK selection in your
501 <filename>.emacs</filename> file so that it applies to all
502 projects. You can configure the JDEE to use different JDKs
503 for different projects by saving your customization in a
504 project file. See <ulink url="#UsingProjectFiles">Using
505 Project Files</ulink> or more information.</para>
513 <title><anchor id="EditingJavaSourceFiles"/>Editing Java Source Files</title>
518 To edit an existing Java source file, load it into an Emacs
519 buffer by executing <command>C-x C-f</command>. Loading a Java source file
520 into a buffer causes the buffer to enter into <function>jde-mode</function>,
521 a variant of <function>java-mode</function>, which is in turn a variant of
522 the standard Emacs <function>cc-mode</function> for editing source files
523 written in C and related languages. <function>jde-mode</function> offers all the
524 specialized source file editing commands of <function>cc-mode</function> plus
525 functions for creating, compiling, building, running, and debugging Java source files.
526 You can invoke the commands by selecting them from the <guimenu>JDE</guimenu>
527 menu that <function>jde-mode</function> displays on the Emacs menu bar or by
528 typing the commands in the Emacs minibuffer.
535 <imagedata fileref="images/jdemenu.gif" width="544" depth="350"/>
538 <phrase>Screenshot showing the JDE menu.</phrase>
550 <title><anchor id="DocumentingCode"/>Documenting Code</title>
553 The JDE provides complete support for generating HTML
554 documentation for Java classes from comments inserted into the
555 source code for those classes.
558 <para>See also</para>
559 <para><ulink url="#DisplayingDoc">Displaying Java
560 Documentation</ulink></para>
565 <title><anchor id="InsertingComments"/>Inserting Javadoc
569 To insert a skeleton javadoc comment for a class or method,
570 position point in the first line of the method or class and
571 select <guimenuitem>JDE->Document</guimenuitem> from the
572 Emacs menubar or type <command>C-c C-v j</command>.
576 To customize the javadoc skeletons, select
577 <guimenuitem>JDE->Options->Project->Javadoc</guimenuitem>
578 from the Emacs menubar.
582 <title>Thanks...</title>
584 to <ulink url="mailto:david@dponce.com">David Ponce</ulink>
585 for developing the JDE's javadoc comment generation
595 <title><anchor id="GeneratingJavadoc"/>Generating the
596 Documentation</title>
600 To generate documentation for the current project, open any
601 source file in the project and select <guimenuitem>Make
602 Doc</guimenuitem> from the <guimenu>JDE</guimenu> menu or
603 enter <command>M-x jde-javadoc-make</command>.
607 The <command>jde-javadoc-make</command> command runs the JDK's
608 javadoc program to generate the documentation. The
609 <command>javadoc</command> command must be on your system's
614 The <command>jde-javadoc-make</command> command uses
615 <varname>jde-global-classpath</varname> as the
616 <varname>-classpath</varname> and <varname>jde-sourcepath
617 </varname> as the <varname>-sourcepath</varname> option for
618 generating the doc. You can specify all other javadoc options
619 via JDE customization variables. To specify the options,
620 select <menuchoice><guimenu>Project</guimenu>
621 <guisubmenu>Options</guisubmenu><guimenuitem>Javadoc</guimenuitem></menuchoice>
625 <menuchoice><guimenu>JDE</guimenu></menuchoice> menu. Use
626 <varname>jde-javadoc-gen-packages</varname> to specify the
627 packages, classes, or source files for which you want to
628 generate javadoc. If this variable is
629 <varname>nil</varname>, the
630 <command>jde-javadoc-make</command> generates javadoc for
631 the Java source file in the current buffer.
636 Thanks to <ulink url="mailto:sakliban@cs.wustl.edu">Sergey A
637 Klibanov </ulink> for developing the JDE's javadoc
648 <title><anchor id="Abbrevs"/>Abbreviations</title>
651 The JDEE allows you to use abbreviations for Java keywords and
652 control flow constructs. The following sections explain how to
653 use these abbreviations.
660 <title><anchor id="KeywordAbbrevs"/>Keyword
661 Abbreviations</title>
663 <para>The JDEE defines a set of abbreviations for Java keywords.
664 When you type one of these abbreviations followed by a space
665 in a Java source buffer, the JDE optionally expands the
666 abbreviation into the keyword. For example, when the
667 abbreviation mode is enabled, you need only type
668 <varname>fa</varname> followed by a space to enter the Java
669 keyword <varname>false</varname>. To enable or disable
670 abbreviation mode by default for a project, select
671 <menuchoice><guimenu moreinfo="none">JDE</guimenu>
673 moreinfo="none">Project</guisubmenu><guisubmenu>Options
674 </guisubmenu><guimenuitem>General</guimenuitem></menuchoice>
675 and toggle the boolean variable
676 <varname>jde-enable-abbrev-mode</varname>. To toggle
677 abbreviation mode on or off during a session, select
679 <guimenu>JDE</guimenu>
680 <guisubmenu>Code Generation</guisubmenu>
681 <guisubmenu>Modes</guisubmenu>
682 <guimenuitem>Abbrev</guimenuitem>
683 </menuchoice>. To change, remove, or add an abbreviation, edit
684 the variable <varname>jde-mode-abbreviations</varname> in the
685 project customization buffer.</para>
687 <note><para>The JDE's Java keyword expansion facility is based
688 on the Emacs <varname>abbrev-mode</varname> facility. For
689 more information, see the Emacs user manual.</para></note>
696 <title><anchor id="ControlFlowAbbrevs"/>Control Flow
697 Abbreviations</title>
699 <para>The JDEE defines abbreviations for Java control flow
700 structures, such as if-then-else. When you enter the
701 abbreviation followed by a space, the JDE expands the
702 abbreviation into a corresponding control structure
706 <title>Expanding a Control Flow Abbreviation</title>
708 <para>The if-then-else abbreviation</para>
714 <para>expands to the control flow structure</para>
717 if ( ) { } // end of if () else } // end of if ()else
722 <title>Control Flow Abbreviations</title>
724 <para>The JDE defines the following abbreviations for control
728 <title>Control Flow Abbreviations</title>
730 <colspec colnum="1"></colspec>
731 <colspec colnum="2"></colspec>
733 <row><entry>Statement</entry><entry>Abbreviation</entry></row>
737 <entry><varname>if-then</varname></entry>
738 <entry><varname>if</varname></entry>
741 <entry><varname>else</varname></entry>
742 <entry><varname>else</varname></entry>
745 <entry><varname>if-then-else</varname></entry>
746 <entry><varname>ife</varname></entry>
749 <entry><varname>else-if</varname></entry>
750 <entry><varname>eif</varname></entry>
753 <entry><varname>while</varname></entry>
754 <entry><varname>while</varname></entry>
757 <entry><varname>for</varname></entry>
758 <entry><varname>for</varname></entry>
761 <entry><varname>for (int
762 I=0;I<UL;I++)</varname></entry>
763 <entry><varname>fori</varname></entry>
766 <entry><varname>for (Iterator i = c.iterator();
767 i.hasNext();)</varname></entry>
768 <entry><varname>foriter</varname></entry>
771 <entry><varname>main method</varname></entry>
772 <entry><varname>main</varname></entry>
775 <entry><varname>switch</varname></entry>
776 <entry><varname>switch</varname></entry>
779 <entry><varname>case</varname></entry>
780 <entry><varname>case</varname></entry>
783 <entry><varname>try</varname></entry>
784 <entry><varname>try</varname></entry>
787 <entry><varname>catch</varname></entry>
788 <entry><varname>catch</varname></entry>
791 <entry><varname>try finally</varname></entry>
792 <entry><varname>tryf</varname></entry>
795 <entry><varname>finally</varname></entry>
796 <entry><varname>finally</varname></entry>
804 You must enable the JDE's Java keyword abbreviation mode
805 to use the control flow abbreviations. See <ulink
806 url="#JavaKeywordCompletion">Java Keyword
807 Completion</ulink> for more information.
814 <title>Left Brace Placement</title>
817 The JDE's Java control flow templates support two options
818 for opening brace placement: placement on the first line of
819 the template (Kerningham & Ritchie Style, the default)
820 and placement on a separate line. Type <command>M-x
821 customize-variable jde-gen-k&r</command> to specify
822 the style you prefer.
829 <title>Customizing the Control Flow Templates</title>
831 <para>You can customize the templates to suit any indentation
832 style. To customize the templates, select
834 <guimenu>Project</guimenu>
835 <guisubmenu>Options</guisubmenu>
836 <guimenuitem>Autocode</guimenuitem>
837 </menuchoice> from the JDE menu.</para>
843 <title>Adding Your Own Control Flow Templates</title>
845 Use the <function>jde-gen-define-abbrev-template</function>
846 function to define your own control flow abbreviation in
847 your <filename>.emacs</filename> file. For example, the
848 following code defines an abbreviation for an else clause.
851 (jde-gen-define-abbrev-template "melse" '('> "else {" '> 'n
855 moreinfo="none">jde-gen-define-abbrev-template</function>
856 function takes two arguments. The first argument is a string
857 that specifies the abbreviation. The section argument is a
858 list defining the text that replaces the abbreviation. The
859 list can contain any of the following elements.</para>
861 <title>Template Elements</title>
865 <entry>Element</entry>
871 <entry>A string.</entry>
872 <entry>The string is inserted into the buffer at
876 <entry>The symbol <varname>'p</varname>.</entry>
877 <entry>This position is saved in
878 <varname>tempo-marks</varname>.</entry>
881 <entry>The symbol <varname>'r</varname>.</entry>
882 <entry>If <varname>tempo-insert</varname> is called
883 with <varname>ON-REGION</varname> non-nil the
884 current region is placed here. Otherwise it works
888 <entry><varname>(p PROMPT <NAME>
889 <NOINSERT>)</varname></entry>
890 <entry>If <varname>tempo-interactive</varname> is
891 non-nil, the user is prompted in the minbuffer with
892 <varname>PROMPT</varname> for a string to be
893 inserted. If the optional parameter
894 <varname>NAME</varname> is non-nil, the text is
895 saved for later insertion with the
896 <varname>s</varname> tag. If there already is
897 something saved under <varname>NAME</varname> that
898 value is used instead and no prompting is made. If
899 <varname>NOINSERT</varname> is provided and non-nil,
900 nothing is inserted, but text is still saved when a
901 <varname>NAME</varname> is provided. For clarity,
902 the symbol <varname>'noinsert</varname> should be
903 used as argument.</entry>
906 <entry><varname>(P PROMPT <NAME>
907 <NOINSERT>)</varname></entry>
908 <entry>Works just like the previous element, but
909 forces <varname>tempo-interactive</varname> to be
913 <entry><varname>(r PROMPT <NAME>
914 <NOINSERT>)</varname></entry>
915 <entry>Like the previous, but if
916 <varname>tempo-interactive</varname> is
917 <varname>nil</varname> and
918 <varname>tempo-insert</varname> is called with
919 <varname>ON-REGION</varname> non-nil, the current
920 region is placed here. This usually happens when you
921 call the template function with a prefix
925 <entry><varname>(s NAME)</varname></entry>
926 <entry>Inserts text previously read with the
927 <varname>(p ..)</varname> construct. Finds the
928 insertion saved under <varname>NAME</varname> and
929 inserts it. Acts like <varname>'p</varname> if
930 <varname>tempo-interactive</varname> is
931 <varname>nil</varname>.</entry>
934 <entry><varname>'&</varname></entry>
935 <entry>If there is only whitespace between the line
936 start and point, nothing happens. Otherwise a
937 newline is inserted.</entry>
940 <entry><varname>'%</varname></entry>
941 <entry>If there is only whitespace between point and
942 end-of-line nothing happens. Otherwise a newline is
946 <entry><varname>'n</varname></entry>
947 <entry>Inserts a newline.</entry>
950 <entry><varname>'></varname></entry>
951 <entry>The line is indented using
952 <varname>indent-according-to-mode</varname>. Note
953 that you often should place this item after the text
954 you want on the line.</entry>
957 <entry><varname>'n></varname></entry>
958 <entry>Inserts a newline and indents line.</entry>
961 <entry><varname>'r></varname></entry>
962 <entry>Like <varname>r</varname>, but it also indents
966 <entry><varname>'o</varname></entry>
967 <entry>Like <varname>'%</varname> but leaves the point
968 before the new line.</entry>
971 <entry>Anything else.</entry>
972 <entry>It is evaluated and the result is treated as an
973 element to be inserted. One additional tag is useful
974 for these cases. If an expression returns a list
975 <varname>'(l foo bar)</varname>, the elements after
976 <varname>'l</varname> will be inserted according to
977 the usual rules. This makes it possible to return
978 several elements from one expression.</entry>
987 <title>Enabling Variable Content</title>
989 <para>Some templates optionally prompt you for items to insert
990 into the template. To enable prompting, set the variable
991 <varname>tempo-interactive</varname> to a
992 non-<varname>nil</varname> value in your
993 <filename>.emacs</filename> file.</para>
997 <title>Disabling the Control Flow Abbreviations</title>
999 <para>To disable the control flow abbreviations, set the
1000 variable <varname>jde-gen-cflow-enable</varname> off.</para>
1003 <title>Thanks to...</title>
1005 <para>Thanks to Eric D. Friedman >friedman@lmi.net<
1006 for contributing the control flow templates.</para>
1018 <title><anchor id="CodeCompletion"/>Completing Expressions</title>
1021 Both Emacs and the JDEE provide commands for completing incomplete
1022 expressions. Emacs provides commands that work for any expression
1023 but only if the completions exist in an open buffer. The JDEE
1024 provides completion commands that work for any Java method or field
1025 name that exists on <varname>jde-global-classpath</varname>.
1026 The following sections explain how to use completion facilities
1027 supplied by the JDEE and by Emacs itself.
1033 <title><anchor id="FieldAndMethodCompletion"/>Completing Method
1034 and Field Names</title>
1038 The JDEE provides comamnds that can complete an incomplete
1039 field or method name. All the methods determine the set of
1040 possible completions for an incomplete field or method name at
1041 point. They differ in how they present the completions to you
1042 for selection. The commands include:</para>
1046 <para><command>jde-complete-in-line</command></para>
1047 <para>This command uses the first completion that it finds
1048 to complete the method or field name at point. If multiple
1049 completions exist, it allows you to cycle through the
1050 completions, each completion replacing the previous in the
1051 source buffer. See <ulink url="#InLineCompletion">Using
1052 In-Line Completion</ulink> for more information.
1056 <para><command>jde-complete-menu</command></para>
1058 This command displays a menu of possible completions for
1059 the incomplete method or field name at point. It enters
1060 the completion that you select in the source buffer. See
1061 <ulink url="#MenuCompletion">Using Menu-Based
1062 Completion</ulink> for more information.
1066 <para><command>jde-complete-minibuf</command></para>
1068 This command uses the minibuffer to display possible
1069 completions for the incomplete method or field name at
1070 point. The comamnd enters the completion that you select
1071 in the source buffer. See <ulink
1072 url="#MinibufferCompletion">Using Minibuffer-Based
1073 Completion</ulink> for more information.</para>
1076 <para><command>jde-complete</command></para>
1077 <para>This is the JDEE's user-definable "standard"
1078 completion command. It delegates completion to one of the
1079 JDEE's other completion commands
1080 (<command>jde-complete-menu</command> by default) or to a
1081 custom completion function that you specify (see <ulink
1082 url="SelectCompletionMethod">Selecting a Completion
1083 Method</ulink> for more information.) The
1084 <command>jde-complete</command> command is bound by
1085 default to the key combination <command>C-c C-v
1086 C-.</command>. If you prefer another binding, use the
1087 customization variable <varname>jde-key-bindings</varname>
1088 to change the binding.
1094 The JDEE's field and method completion commands use the
1095 Beanshell to run Java code that in turn uses Java's reflection
1096 (class introspection) capability to determine the fields and
1097 methods defined for the class of object at point. The commands
1098 start the Beanshell if it is not running. This can cause a
1099 noticeable delay in completion the first time it is used in a
1100 session. The response can also be slow for classes containing
1101 many methods and fields.
1105 <para>See <ulink url="#SpeedingUpCompletion">Speeding Up Completion</ulink>
1106 for some tips on how you can dramatically speed up field and
1107 method completion.</para>
1111 Completion works only for compiled classes that reside in the
1112 classpath defined by <varname>jde-global-classpath</varname>,
1113 if set, otherwise by the <varname>CLASSPATH</varname>
1114 environment variable when the Beanshell starts. Thus, if the
1115 JDEE is unable to complete a method or field, make sure that
1116 the class that defines the field or method is compiled and
1117 exists on the classpath defined by
1118 <varname>jde-global-classpath</varname>, if set, otherwise by
1119 the <varname>CLASSPATH</varname> environment variable.
1124 The JDEE completion commands work for all of the following
1130 <para>objects referenced by variables declared in the
1131 current buffer</para>
1134 <para>static fields and methods</para>
1138 fields and methods of objects defined by the current class
1142 Names of fields and methods of the current class must
1143 start with <varname>this</varname> or <varname>.</varname>
1144 (period). Names of fields and methods declared by the
1145 parent of the current class must start with
1146 <varname>super</varname>.
1148 <para>For example, this command completes</para>
1150 . ^ this. ^ super. ^
1156 objects referenced by the fields of objects referenced by
1157 variables declared in the current class or its parent or
1160 <para>For example, this command completes</para>
1168 objects returned by methods of objects referenced by
1169 variables defined in the current
1172 For example, this command completes
1175 Toolkit.getDefaultToolkit().get ^
1181 objects referenced by method parameters</para>
1183 For example, this command completes
1186 void setColor(String color) { color.get ^ }
1194 <title><anchor id="SelectStdCompletionMethod"/> Selecting a
1195 Completion Method</title>
1197 <para>The JDEE's generic completion command,
1198 <command>jde-complete</command> delegates completion to one
1199 of several specific completion commands supplied by the JDEE
1200 or to a custom completion method that you supply. This
1201 allows you to customize <command>jde-complete</command> to
1202 use the completion method that you prefer.</para>
1204 <para>To specify your preferred completion method:</para>
1210 <para>Open a customization buffer for
1211 <varname>jde-complete-function</varname>.</para>
1216 <imagedata fileref="images/completion_sel_method.gif"/>
1223 <para>Select the completion command that implements the
1224 completion method you prefer.</para>
1228 <para>If you selected <varname>Custom</varname> as your
1229 preferred completion function, enter the name of the
1230 custom completion function in the adjacent edit field,
1231 replacing the existing contents
1232 (<varname>ignore</varname> by default.).
1237 <para>Save your selection in your
1238 <filename>.emacs</filename> or project file.
1248 <title><anchor id="MenuCompletion"/>Using Menu-Based
1250 <para>The <command>jde-complete-menu</command> displays a
1251 popup menu of completions for the method or field name at
1252 point. Selecting a completion from the menu causes the
1253 command to use it to complete the method or field at point.
1254 This section assumes that you have selected
1255 <command>jde-complete-menu</command> as your standard
1259 <para>To select completions from a menu:</para>
1263 <para>Position point immediately following the partially
1264 complete field or method name.</para>
1269 <imagedata fileref="./images/completion_menu1.gif"/>
1277 <para>Type the <command>C-c C-v C-.</command> key combination.</para>
1279 <para>A menu of completions pops up.</para>
1284 <imagedata fileref="./images/completion_menu2.gif"/>
1292 <para>Select the desired completion from the menu.</para>
1294 <para>The JDEE inserts the completion at point in the
1300 <imagedata fileref="./images/completion_menu3.gif"/>
1314 <title><anchor id="InLineCompletion"/>Using In-Line
1318 The <command>jde-complete-in-line</command> command allows
1319 you to select completions at the point of insertion in the
1320 source buffer. The command finds all the fields and methods
1321 that complete the name at point. It then inserts the first
1322 potential completion in the buffer at point. Repeatedly
1323 executing the command causes the JDEE to cycle through the
1324 other potential completions. If the completion is a method
1325 name, the command completes the method name and displays the
1326 method signature in the minibuffer.
1330 The <command>jde-complete-in-line</command> command is bound
1331 to <command>C-c C-v .</command>. You can use this
1332 combination to invoke the command or <command>C-c C-v
1333 C-.</command>, if you have selected this command as your
1334 preferred completion method. The following examples use the
1335 <command>C-c C-v .</command> combination.
1340 <title>Completing a String Method Name</title>
1343 <keycombo><keysym>C-c</keysym><keysym>C-v</keysym><keysym>.</keysym></keycombo>
1350 completes the method name at point as follows</para>
1353 String s; s.getClass( ^
1356 <para>and displays</para>
1359 java.lang.Class getClass()
1362 <para>in the minibuffer. Repeatedly typing
1363 <keycombo><keysym>C-c</keysym><keysym>C-v</keysym><keysym>.</keysym></keycombo>
1364 cycles through all the other get methods for the Java
1365 <varname>String</varname> class.</para>
1372 <title><anchor id="SpeedingUpCompletion"/>Speeding Up Completion</title>
1374 <para>Here are two ways you can significantly speed up field
1375 and method completion:
1380 <para>Byte-compile the eieio and JDEE packages.</para>
1382 <para>The beanshell package, the Emacs interface to the
1383 BeanShell, is based on the eieio object-oriented Lisp
1384 package for Emacs. Completion uses the BeanShell heavily
1385 to determine the class of the field or method at point.
1386 Thus compiling eieio and beanshell.el improves
1387 completion's performance, dramatically in my tests.
1393 <para>Import by class, not by package, in your Java files.
1396 <para>Every package import, e.g.,
1397 <filename>java.util.*</filename>, requires invoking the
1398 BeanShell to determine the fully qualified name of the
1400 <function>jde-parse-get-qualified-name</function>).
1401 A Beanshell invocation is by far the most time-consuming
1402 operation required for completion. Thus eliminating the
1403 use of package-level imports can significantly
1404 speed up completion.
1419 <title><anchor id="DynamicKeywordCompletion"/>Dynamic Keyword Completion</title>
1421 <para>Emacs provides dynamic completion commands that attempt
1422 to find completions for the word at point in the current
1423 buffer or other buffers.
1427 <title>Using Dynamic Completion</title>
1430 Suppose that the current source buffer contains the class
1431 names <varname>Component</varname> and
1432 <varname>Container</varname>. Now suppose you enter
1433 <varname>Co</varname> somewhere in the buffer and type
1434 <keycombo><keycap>M</keycap><keycap>/</keycap></keycombo>.
1436 The text <varname>Component</varname> replaces
1437 <varname>Co</varname> in the buffer.
1441 <keycombo><keycap>M</keycap><keycap>/</keycap></keycombo>
1442 again changes <varname>Component</varname> to
1443 <varname>Container</varname>. In this way, you can cycle
1444 through all the possible completions for
1445 <varname>Co</varname> in the current buffer.
1450 <title>Dynamic Completion Commands</title>
1452 <para>Emacs provides two dynamic completion commands.</para>
1454 The <command>dabbrev-expand</command> command is bound to
1456 <keycombo><keycap>M</keycap><keycap>/</keycap></keycombo>
1457 by default. It searches the current buffer for completions
1458 of the word at point and, if none are found, other buffers
1459 of the same type. For example, if the current buffer is a
1460 Java source buffer, it searches other Java source buffers
1461 for completions if none are found in the active buffer.
1465 The <command>hippie-expand</command> command provides more
1466 extensive search capabilities. See the docstrings for these
1467 functions for more information.
1473 <title>Electric Return</title>
1474 <para>In electric return mode, pressing the
1475 <keycap>Enter</keycap> key causes the JDEE to close open
1476 braces at the end of a line. To enable or disable this
1477 mode by default, customize <varname>jde-electric-return-p</varname>.
1478 To turn the mode on or off during a session, select <menuchoice>
1479 <guimenu>JDE</guimenu>
1480 <guisubmenu>Code Generation</guisubmenu>
1481 <guisubmenu>Modes</guisubmenu>
1482 <guimenuitem>Electric Return</guimenuitem>
1483 </menuchoice>.</para>
1493 <title><anchor id="GeneratingCode"/>Generating Code</title>
1495 <para>The JDE provides the following code generation capabilities.</para>
1498 <listitem><para>Code wizards</para></listitem>
1499 <listitem><para>Code templates</para></listitem>
1504 <title><anchor id="GeneratingImportStatements"/>Generating Import Statements</title>
1506 <para>The JDEE provides a set of commands that generate and
1507 organize import statements in the current buffer. The commands
1508 automate the following tasks:</para>
1512 <para>Generate an import statement for the class at point (see
1513 <ulink url="#ImportingClasses">Importing Classes</ulink>).</para>
1516 <para>Generate import statements for all classes in the current
1517 buffer that need import statements (see
1518 <ulink url="#ImportingAllClasses">Importing All Classes</ulink>).</para>
1521 <para>Expand a package import statement into specific class imports (see
1522 <ulink url="#ExpandingPackageImports">Expanding Package Imports</ulink>).</para>
1525 <para>Collapse class imports into a package import statement (see
1526 <ulink url="#CollapsingClassImports">Collapsing Class Imports</ulink>).</para>
1529 <para>Group import statements (see
1530 <ulink url="#GroupingImports">Grouping Imports</ulink>).</para>
1533 <para>Sort import statements alphabetically (see
1534 <ulink url="#SortingImports">Sorting Imports</ulink>).</para>
1537 <para>Delete superfluous import statements (see
1538 <ulink url="#DeletingImports">Deleting Imports</ulink>).</para>
1546 <title><anchor id="ImportingClasses"/>Importing Classes</title>
1550 <guimenu>JDE</guimenu>
1551 <guisubmenu>Import</guisubmenu><guimenuitem>Class</guimenuitem></menuchoice>
1552 (<command>jde-import-find-and-import</command>,
1553 <keycombo><keycap>C</keycap><keycap>c</keycap></keycombo>
1554 <keycombo><keycap>C</keycap><keycap>v</keycap></keycombo>
1555 <keycombo><keycap>C</keycap><keycap>z</keycap></keycombo>) command
1556 generates an import statement for the
1557 class at point in the current buffer. It inserts the import
1558 statement at the head of the buffer.
1561 <para>This command uses the BeanShell to search the classpath
1562 of the current project for classes that match the name of
1563 the class at point. The class name may be unqualified.</para>
1567 The classpath that the import wizard searches for import
1568 candidates is the classpath specified by the value of
1569 <varname>jde-global-classpath</varname> for the current
1575 <para>If the command finds more than one class of the same
1576 unqualified name on the current classpath, it prompts you to
1577 select one of the classes to import.</para>
1581 The customization variable
1582 <varname>jde-import-excluded-classes</varname> allows
1583 you to specify rules for excluding classes from
1584 consideration for import into the current source file. If
1585 the import command finds any classes on the classpath that
1586 belong to the list of prohibited classes, it removes them
1587 from the list of classes considered for import into the
1591 <para>You can use either regular expressions or Lisp functions to
1592 specify class exclusion rules. For each rule, you can also
1593 specify that all classes whose unqualified names match the
1594 rule be excluded from consideration for import. This is
1595 useful for preventing the JDEE from importing alternate
1596 implementations of standard Java classes that do not need to
1599 <para>For example, the default setting for
1600 <varname>jde-import-excluded-classes</varname> includes a
1601 rule to exclude all classes belonging to the
1602 <varname>java.lang</varname> package because every Java
1603 class implicitly imports this package. The default setting
1604 for <varname>jde-import-excluded-classes</varname> also
1605 excludes all unqualified synonyms of classes belonging to
1606 the <varname>java.lang</varname> package. This prevents
1607 importation of alternate implementations of these classes,
1608 e.g., alternate implementations of
1609 <varname>java.lang.String</varname>, included in some
1610 commonly used class libraries and intended for internal use.
1611 See the docstring for
1612 <varname>jde-import-excluded-classes</varname> for more
1616 <title>Thanks to ...</title>
1617 <para><ulink url="mailto:len@reeltwo.com">Len
1618 Trigg</ulink> for contributing the initial
1619 implementation of the import wizard and to
1620 Martin Schwarmberger for significantly
1621 enhancing the import wizard.
1631 <title><anchor id="ImportingAllClasses"/>Importing All Classes</title>
1633 <para>The <menuchoice>
1634 <guimenu>JDE</guimenu>
1635 <guisubmenu>Code Generation</guisubmenu>
1636 <guisubmenu>Import</guisubmenu>
1637 <guimenuitem>All</guimenuitem>
1638 </menuchoice> (<command>jde-import-all</command>,
1649 ) imports all the classes that need to be
1650 imported into the current buffer.
1654 The command imports all classes that meet the following
1659 <para>The class's base name begins with an uppercase letter.</para>
1662 <para>The class's base name contains at least one noninitial
1663 lowercase letter.</para>
1666 <para>The class is not already imported into the buffer.</para>
1669 <para>The class is not in
1670 <varname>jde-import-excluded-classes</varname>.</para>
1673 <para>The class exists on the current classpath.</para>
1677 <para>If more than one import candidate with the same base
1678 name exists on the classpath, the JDEE displays a dialog
1679 that allows you to select one of the candidates.</para>
1683 <para>You can use the <menuchoice>
1684 <guimenu>JDE</guimenu>
1685 <guisubmenu>Code Generation</guisubmenu>
1686 <guisubmenu>Import</guisubmenu>
1687 <guimenuitem>Import All Unique</guimenuitem>
1688 </menuchoice> (<command>jde-import-all-unique</command>
1689 ) command to avoid the dialog box. This command imports all classes
1690 whose unqualified names appear only once on the classpath.</para>
1695 <title>Thanks to ...</title>
1696 <para><ulink url="mailto:p.lord@russet.org.uk">Phillip
1697 Lord</ulink> for contributing the initial implementation
1698 of the Import All Wizard.</para>
1706 <title><anchor id="ExpandingPackageImports"/>Expanding Package Imports</title>
1707 <para>To expand a package import statement, select <menuchoice>
1708 <guimenu>JDE</guimenu>
1709 <guisubmenu>Code Generation</guisubmenu>
1710 <guisubmenu>Import</guisubmenu>
1711 <guisubmenu>Expand Package Imports</guisubmenu>
1713 (<command>jde-import-expand-imports</command>). This command replaces
1714 a package import statement, e.g.,
1717 <para><programlisting>
1719 </programlisting></para>
1720 <para>with import statements for the members of that package referenced
1721 by the current buffer, e.g.,</para>
1722 <para><programlisting>
1723 import java.io.BufferedReader;
1724 import java.io.InputStreamReader;
1725 import java.io.IOException;
1726 </programlisting></para>
1732 <title><anchor id="CollapsingClassImports"/>Collapsing Class Imports</title>
1733 <para>To collapse class import statements in the current buffer into
1734 package imports, select <menuchoice>
1735 <guimenu>JDE</guimenu>
1736 <guisubmenu>Code Generation</guisubmenu>
1737 <guisubmenu>Import</guisubmenu>
1738 <guisubmenu>Collapse Class Imports</guisubmenu>
1739 </menuchoice> (<command>jde-import-collapse-imports</command>). This command
1740 collapses imports for any package that contains as many as or more than the
1741 number of imports specified by <varname>jde-import-collapse-imports-threshhold</varname>.
1742 The default value of this variable is 2. This causes this command to collapse
1743 imports for any package from which the current buffer imports two or more classes.
1744 For example, this command, by default, collapses
1747 import java.io.BufferedReader;
1748 import java.io.InputStreamReader;
1749 import java.io.IOException;
1758 <title><anchor id="GroupingImports"/>Grouping Imports</title>
1759 <para>To organize import statements into groups of related imports, select
1761 <guimenu>JDE</guimenu>
1762 <guisubmenu>Code Generation</guisubmenu>
1763 <guisubmenu>Import</guisubmenu>
1764 <guisubmenu>Organize Imports</guisubmenu>
1765 </menuchoice> (<command>jde-import-organize</command>). By default this command
1766 groups import statements into two groups separated by a blank line. The first
1767 group contains all imports from the java and javax packages. The other group
1768 contains imports from all other packages. The imports are sorted alphabetically
1769 in ascending order in each group, e.g.,
1772 import java.io.InputStreamReader;
1773 import java.util.Hashtable;
1774 import javax.swing.JFrame;
1775 import javax.swing.JPanel;
1777 import jmath.LinearSystem;
1780 <para>The following variables allow you to customize the organization of imports
1784 <para><varname>jde-import-group-function</varname></para>
1785 <para>This variable allows you to specify a function that assigns imports
1786 to groups. The default group function is <function>jde-import-group-of</function>,
1787 which uses rules specified by the following variable to assign imports to
1791 <para><varname>jde-import-group-rules</varname></para>
1792 <para>This variable specifies a list of rules for assigning import statements to
1793 group, e.g., <filename>'(("^javax\\." . "Swing"))</filename>,
1794 Each rule consists of two parts: a regular expression and an optional
1795 group name specifier. The <function>jde-import-group-of</function> function assigns
1796 an import statement to the group if it matches the regular expression. The group name
1797 specifier is either a string that specifies the name or an index to a component of the regular
1798 expression to be used as the group name.</para>
1801 <para><varname>jde-import-insert-group-names</varname></para>
1802 <para>Specifies whether to insert an import group's name in the buffer.</para>
1805 <para><varname>jde-import-default-group-name</varname></para>
1806 <para>Specifies the default name for an import group.</para>
1809 <para><varname>jde-import-blank-line-between-groups</varname></para>
1810 <para>Specifies whether to insert a blank line between import groups.</para>
1813 <para><varname>jde-import-sorted-groups</varname></para>
1814 <para>Specifies whether and how to sort groups of packages. Options include
1815 no sorting, in the order specified by grouping rules, or in ascending or
1816 descending alphabetical order.</para>
1822 <title><anchor id="DeletingUnneededImports"/>Deleting Unneeded Imports</title>
1825 To delete superfluous import statements from the current buffer, select
1827 <guimenu>JDE</guimenu>
1828 <guisubmenu>Code Generation</guisubmenu>
1829 <guisubmenu>Import</guisubmenu>
1830 <guisubmenu>Delete Unneeded</guisubmenu>
1832 (<command>jde-import-kill-extra-imports</command>). This command deletes all
1833 import statements for classes that are not actually referenced by the class
1834 in the current buffer.
1845 <title><anchor id="CodeWizards"/>Code Wizards</title>
1848 The JDE provides a set of procedural code generators called
1849 code wizards. They include:
1853 <title>Code Wizards</title>
1857 <entry><para>Wizard</para></entry>
1858 <entry><para>Generates...</para></entry>
1864 <para><ulink url="#MethodOverrideWizard">Method
1865 Override Wizard</ulink></para>
1868 <para> A method that overrides a method inherited by
1869 the class containing point. </para>
1874 <para><ulink url="#InterfaceWizard">Interface
1875 Wizard</ulink></para>
1878 <para>Implementation of an interface in the class
1879 containing point. </para>
1884 <para><ulink url="#DelegateWizard">Delegate
1885 Wizard</ulink></para>
1888 <para> Methods that delegate tasks to a specified
1894 <para><ulink url="#AbstractClassWizard">Abstract Class
1895 Wizard</ulink></para>
1898 <para>Implementations of the abstract methods
1899 inherited by the class containing point. </para>
1904 <para><ulink url="#GetSetWizard">Get/Set
1905 Wizard</ulink></para>
1908 <para>Get and set methods for the private fields of
1909 the class containing point. </para>
1918 Some of the wizards use the BeanShell to run Java code. A
1919 wizard starts the Beanshell interpreter if it is not already
1920 running. Thus, you may experience a slight delay when
1921 invoking a wizard for the first time in a session.
1929 <title><anchor id="MethodOverrideWizard"/>Method Override
1933 The method override wizard generates a skeleton method that
1934 overrides a similarly named method defined by a superclass.
1937 <para>To override a method of a superclass: </para>
1943 Position the Emacs point at the location in the buffer
1944 where you want the generated method to appear.
1947 The point must be within the class that is overriding
1954 <imagedata fileref="images/OverrideMeth1.gif" width="472" depth="328"/>
1957 <phrase>Screen capture showing point inside a
1969 <menuchoice><guisubmenu>Wizards</guisubmenu><guimenuitem>Override
1970 Method</guimenuitem>
1971 </menuchoice> from the
1972 <menuchoice><guimenu>JDE</guimenu>
1973 </menuchoice> menu or enter
1974 <keycombo><keycap>M</keycap><keycap>x</keycap>
1975 </keycombo> <varname>jde-wiz-overrided-method</varname>.
1981 <imagedata fileref="images/OverrideMeth2.gif"/>
1983 <textobject><phrase>Screen shot showing
1984 <menuchoice><guimenu>Wizards</guimenu>
1985 </menuchoice> menu.</phrase>
1992 The JDE prompts you to enter the name of the method to
1993 be overridden in the minibuffer.
1999 <imagedata fileref="images/OverrideMeth3.gif"/>
2001 <textobject><phrase>Screen shot showing prompt for
2002 method name. </phrase>
2009 The name must be the name of a method defined by an
2010 ancestor of the class in which the Emacs point is
2011 located. The compiled class of the ancestor must be on
2012 the classpath specified by
2013 <varname>jde-global-classpath</varname>.
2019 Enter the name of the method to be overridden.
2022 If the ancestors of the class in which you are
2023 overriding the method define more than one method of the
2024 same name, the wizard displays a dialog buffer that
2025 lists the methods. For example, Java's awt class
2026 hierarchy defines several variants of the method
2027 <varname>repaint</varname>. If you specify
2028 <varname>repaint</varname> as the method to override,
2029 the JDE displays the following dialog buffer:
2035 <imagedata fileref="images/OverrideMeth4.gif"/>
2037 <textobject><phrase>Screen shot showing dialog
2038 buffer for selecting method. </phrase>
2045 The dialog buffer lists the signature of each variant of
2046 the method you specified. Next to each signature is a
2047 radio button. The radio button of the currently selected
2048 signature contains an asterisk. To select another
2049 signature, right-click the radio button next to the
2050 variant. To confirm your selection and dismiss the
2051 dialog, right-click the <guibutton>[Ok]</guibutton>
2058 Select the method variant you want to override and click
2059 the <guibutton>[Ok]</guibutton> button.
2061 <para>The wizard inserts a skeleton implementation of
2062 the selected method at the current point in the Java
2063 source buffer.</para>
2069 <imagedata fileref="images/OverrideMeth5.gif"/>
2071 <textobject><phrase>Screen shot showing the inserted
2079 The wizard also inserts import statements for any
2080 classes referenced by the method that are not already
2081 imported by the containing class either explicitly or
2082 implicitly. The wizard inserts the import statements at
2083 the head of the source buffer after any existing import
2084 statements, or any package statement, or the first blank
2088 The method override wizard uses the BeanShell to
2089 create the interface implementation. If the BeanShell
2090 is not currently running, the wizard starts the
2091 BeanShell. Thus, if the BeanShell is not already
2092 running, you may experience a short pause the first
2093 time you override a method.
2104 <title><anchor id="InterfaceWizard"/>Interface Wizard</title>
2107 This wizard creates a skeleton implementation of any
2108 interface defined on the classpath specified by
2109 <varname>jde-global-classpath</varname>.
2112 <para>To create an implementation of an interface: </para>
2117 If the interface is to be implemented by a new class,
2118 create the class in a buffer.
2123 Position the Emacs point at the point in the class where
2124 you want the implementation of the interface's methods
2131 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Wizards</guisubmenu>
2132 <guimenuitem>Implement Interface</guimenuitem>
2133 </menuchoice> or enter
2134 <keycombo><keycap>M</keycap><keycap>x
2135 </keycap></keycombo><varname>jde-wiz-implement-interface</varname>.
2142 The JDE prompts you to enter the name of the interface
2147 <para>Enter the fully qualified name of the interface, for
2149 <classname>java.awt.Event.MouseListener</classname>.</para>
2151 The wizard inserts skeleton implementations of the
2152 methods declared by the interface at the current point
2153 in the current buffer. It inserts import statements for
2154 any classes required by the interface at the head of the
2155 current buffer (only if import statements do not already
2156 exist for the required classes). It also updates or
2157 creates an implements clause for the class.
2163 The interface wizard uses the BeanShell to create the
2164 interface implementation. If the BeanShell is not
2165 currently running, it starts the BeanShell. Thus, if the
2166 BeanShell is not already running, you may experience a
2167 short pause the first time you use the wizard. </para>
2171 <title>Thanks to ...</title>
2172 <para><ulink url="mailto:friedman@lmi.net">Eric
2173 Friedman</ulink> for creating the framework for the
2174 interface, method override, and abstract class wizards and
2175 for contributing the initial implementation of the
2176 interface wizard.</para>
2184 <title><anchor id="DelegateWizard"/>Delegate Wizard</title>
2188 This wizard generates methods that delegate calls to a class
2189 in the current buffer to an attribute of the class, i.e., to
2190 an object that is a field of the current class. For example,
2191 if the current buffer contains class
2192 <classname>A</classname> and <classname>A</classname> has
2193 an attribute, <varname>A.b</varname>, that is an instance
2194 of class <classname>B</classname>, this wizard generates
2195 all the public methods of class <classname>B</classname> in
2196 <classname>A</classname> and delegates handling of those
2197 methods to <varname>b</varname>.
2200 <note><title>Thanks to...</title>
2202 <ulink url="mailto:cfhart@Z-TEL.com">Charles Hart</ulink>
2203 for contributing this wizard.
2210 <title><anchor id="GetSetWizard"/>Get/Set Wizard</title>
2213 This wizard generates get and set methods for the private
2214 fields of the class at point, but only if the fields do not
2215 already have get or set methods. To generate the methods,
2216 move point to the point in the class where you want the get
2217 and set methods to appear. Then select
2218 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Code
2219 Generation</guisubmenu>
2220 <guisubmenu>Wizards</guisubmenu>
2221 <guimenuitem>Generate Get/Set Methods...</guimenuitem>
2222 </menuchoice> or enter
2223 <keycombo><keycap>M</keycap><keycap>x </keycap></keycombo>
2224 <varname>jde-wiz-get-set-methods</varname>
2228 <title>Thanks to...</title>
2230 <ulink url="mailto:jslopez@forumsys.com">Javier
2231 Lopez</ulink> and <ulink
2232 url="mailto:sandip.chitale@brokat.com">Sandip
2233 Chitale</ulink> for contributing this wizard.
2245 <title><anchor id="CodeTemplates"/>Code Templates</title>
2250 <title><anchor id="BufferTemplates"/>Buffer Templates</title>
2252 <para>These commands create buffers containing a skeleton Java class.
2253 Each command prompts you to enter the path to a new Java source
2254 file. They then create a buffer for the new file and insert a
2255 template for a class of the same name as the newly created file.
2256 In particular, the command </para>
2261 <menuchoice><guimenu>Files</guimenu><guisubmenu>JDE New</guisubmenu><guimenuitem>Class</guimenuitem></menuchoice> creates a buffer containing a generic Java public class.
2267 <menuchoice><guimenu>Files</guimenu><guisubmenu>JDE New</guisubmenu><guimenuitem>Console</guimenuitem></menuchoice> creates a buffer containing the main class of a
2268 Java console application.
2274 <menuchoice><guimenu>Files</guimenu><guisubmenu>JDE New</guisubmenu><guimenuitem>Other</guimenuitem></menuchoice> prompts you to create any of the above buffers or a
2275 custom (user-defined) buffer.
2282 You can create an empty Java class buffer by selecting
2283 <menuchoice><guimenu>Files</guimenu><guisubmenu>Open</guisubmenu></menuchoice>
2284 (<keycombo><keycap>C</keycap><keycap>x</keycap></keycombo> <keysym>f</keysym>) and
2285 entering the path for a new file whose root name is the same as
2286 the class you want to create and whose extension is <filename>.java.</filename>
2290 <title>Specifying Boilerplate Text</title>
2293 You can specify boilerplate text (for example, a copyright
2294 notice) to be inserted at the head of class source files
2295 created by the JDE. The JDE provides two ways to specify
2296 the boilerplate text. The simplest way is to enter the
2297 lines of boilerplate text as the value of the
2298 customization variable
2299 <varname>jde-gen-buffer-boilerplate</varname>. Another way
2300 to specify the text is to set the value of the
2301 customization variable
2302 <varname>jde-gen-boilerplate-function</varname>to a
2303 function that generates the boilerplate text. (The default
2304 value of this variable is
2305 <varname>jde-gen-create-buffer-boilerplate</varname>,
2306 which returns the value of the boilerplate variable,
2307 <varname>jde-gen-buffer-boilerplate</varname>). The
2308 functional approach allows you to generate boilerplate
2309 text dynamically by evaluating the appropriate Lisp code.
2310 By saving the values of boilerplate variables in project
2311 files, you can specify different boilerplate text for each
2318 <title>Customization Variables</title>
2320 <para>The following JDE customization variables control creation of
2321 autocoded Java source buffers:
2327 <colspec colnum="1"></colspec>
2328 <colspec colnum="2"></colspec>
2329 <colspec colnum="3"></colspec>
2332 <entry>Variable</entry>
2333 <entry>Group</entry>
2334 <entry>Usage</entry>
2339 <entry><varname>jde-gen-class-buffer-template</varname></entry>
2340 <entry>Autocode</entry>
2341 <entry>Template for a generic public class buffer.</entry>
2344 <entry><varname>jde-gen-console-buffer-template</varname></entry>
2345 <entry>Autocode</entry>
2346 <entry>Template for a console application buffer.</entry>
2349 <entry><varname>jde-gen-jfc-app-buffer-template</varname></entry>
2350 <entry>Autocode</entry>
2351 <entry>Template for a JFC (Swing) application.</entry>
2354 <entry><varname>jde-gen-junit-test-class-buffer-template</varname></entry>
2355 <entry>Autocode</entry>
2356 <entry>Template for a JUnit test case class. This template requires
2357 the <ulink url="http://www.junit.org">JUnit</ulink> test framework.</entry>
2361 <entry><varname>jde-gen-buffer-templates</varname></entry>
2362 <entry>Autocode</entry>
2363 <entry>Specifies templates available to create
2364 Java buffers.</entry>
2367 <entry><varname>jde-gen-buffer-boilerplate</varname></entry>
2368 <entry>Autocode</entry>
2369 <entry>Specifies lines of text to be inserted
2370 at the head of class files.</entry>
2373 <entry><varname>jde-gen-boilerplate-function</varname></entry>
2374 <entry>Autocode</entry>
2375 <entry>Specifies a function that returns a string
2376 of boilerplate text. The default value is
2377 <varname>jde-gen-create-buffer-boilerplate</varname>, which returns
2378 the value of <varname>jde-gen-buffer-boilerplate</varname>.</entry>
2385 See <ulink url="#CustomizingTemplates">Customizing
2386 Templates</ulink> for information on how to customize
2387 the class creation templates. </para>
2396 <title><anchor id="PointTemplates"/>Point Templates</title>
2399 <para>The following commands insert templates at the current
2400 point in the buffer: </para>
2405 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2406 <guimenuitem>Get/Set Pair </guimenuitem></menuchoice>
2407 generates an instance variable and a get and set method .
2413 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2414 <guimenuitem>Println </guimenuitem></menuchoice>
2416 <programlisting>System.out.println(...);</programlisting>
2422 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2423 <guimenuitem>Action </guimenuitem></menuchoice>
2424 generates and registers an action listener for a
2425 specified component.
2430 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2431 <guisubmenu>Listener</guisubmenu><guimenuitem>Window
2432 </guimenuitem></menuchoice>
2433 generates and registers a window listener for a specified
2439 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2440 <guisubmenu>Listener</guisubmenu><guimenuitem>Mouse
2441 </guimenuitem></menuchoice>
2442 generates and registers a mouse listener for a specified
2448 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2449 <guimenuitem>Other </guimenuitem></menuchoice>
2450 allows you to select any of the above templates or a
2451 custom (user-defined) template.
2456 <para>The following variables control generation of code at
2463 <colspec colnum="1"></colspec>
2464 <colspec colnum="2"></colspec>
2465 <colspec colnum="3"></colspec>
2468 <entry>Variable</entry>
2469 <entry>Group</entry>
2470 <entry>Usage</entry>
2475 <entry><varname>jde-gen-get-set-var-template</varname></entry>
2476 <entry>Autocode</entry>
2477 <entry>Defines a get/set method pair template.</entry>
2480 <entry><varname>jde-gen-listener-action-template</varname></entry>
2481 <entry>Autocode</entry>
2482 <entry>Defines an action listener template.</entry>
2485 <entry><varname>jde-gen-listener-window-template</varname></entry>
2486 <entry>Autocode</entry>
2487 <entry>Defines a window listener template.</entry>
2490 <entry><varname>jde-gen-listener-mouse-template</varname></entry>
2491 <entry>Autocode</entry>
2492 <entry>Defines a mouse listener template.</entry>
2495 <entry><varname>jde-gen-inner-class-template</varname></entry>
2496 <entry>Autocode</entry>
2497 <entry>Defines a template for creating a class inside
2498 another class or inside an existing source
2502 <entry><varname>jde-gen-code-templates</varname></entry>
2503 <entry>Autocode</entry>
2504 <entry>Specifies available code templates.</entry>
2515 <ulink url="#CustomizingTemplates">Customizing
2516 Templates</ulink> for information on how to customize
2517 templates provided by the JDE.
2522 <ulink url="#CreatingTemplates">Creating
2523 Templates</ulink> for information on how to create
2524 templates from scratch.
2534 <title><anchor id="CustomizingTemplates"/>Customizing
2537 <para>You can customize the JDE's standard code templates,
2538 using the Emacs customization feature. </para>
2540 <para>To customize an autocode template: </para>
2544 <para>Select <menuchoice>
2545 <guimenu>JDE</guimenu>
2546 <guisubmenu>Options</guisubmenu>
2547 <guimenuitem>Autocode</guimenuitem></menuchoice></para>
2548 <para>The JDE displays a customization buffer containing
2549 the autocode templates. </para>
2552 <para>Edit the template to suit your needs.</para>
2553 <para>The JDE uses the template format defined by
2554 <filename>tempo.el</filename> to represent class
2555 templates. Each template consists of a list of strings,
2556 symbols, and functions, each of which represents content
2557 to be inserted successively into the buffer at the
2558 current point. The strings represent fixed content. The
2559 symbols and functions represent variable content. See
2560 the docstring for the function
2561 <varname>tempo-define-template</varname> for more
2562 information, including the meaning of special symbols
2563 such as <varname>'n</varname>. </para>
2566 <para>Select the state button associated with the
2568 <para>A menu pops up with a list of options for saving
2569 your changes. </para>
2572 <para>Save your changes.</para>
2574 <menuchoice><guimenuitem>Save for Future
2575 Sessions</guimenuitem></menuchoice> if you want
2576 your changes to apply to all projects. If you want your changes to apply
2577 only to the current projects, select <menuchoice>
2578 <guimenuitem>Set for Current
2579 Session</guimenuitem></menuchoice>. Then select
2581 <guimenu>JDE</guimenu>
2582 <guisubmenu>Options</guisubmenu>
2583 <guimenuitem>Save Project</guimenuitem></menuchoice>
2584 to save your changes in the current project's project
2594 <title><anchor id="CreatingTemplates"/>Creating Templates</title>
2596 <para>The JDE considers any command (interactive function) that
2597 inserts code into a buffer at point to be a template. The JDE
2598 uses the Emacs tempo library to create built-in templates.
2599 You can use tempo to create your own, add-on templates (see below
2600 and the doc for the <varname>tempo-define-template </varname>for
2601 more information) or create templates from scratch.
2602 In either case, once you have created a template, you can add it
2603 to the JDE's lists of available code and/or buffer templates,
2604 using the JDE's <varname>jde-gen-code-templates</varname> and/or
2605 <varname>jde-gen-buffer-templates</varname>
2606 variables, respectively. Adding a template to these lists enables
2607 you to invoke the templates from the JDE menus. When adding a
2608 template, you need to specify a unique title for the template.
2609 These titles enable you to specify the templates when invoking
2610 them, using the JDE's custom code template commands
2611 (<menuchoice><guimenu>Files</guimenu>
2612 <guisubmenu>JDE New</guisubmenu>
2613 <guimenuitem>Custom</guimenuitem></menuchoice> and
2614 <menuchoice><guimenuitem>JDE</guimenuitem>
2615 <guisubmenu>Generate</guisubmenu>
2616 <guimenuitem>Custom</guimenuitem></menuchoice>). You can use
2617 auto completion to enter a template title when invoking a custom
2618 code generation command. Note that you can specify different sets
2619 of templates for different projects, by setting and saving the
2620 template list variables in project files. See the following
2621 sections for more information: </para>
2625 <para><ulink url="#DefiningTemplate">Defining a Template and
2626 Template Insertion Function</ulink></para>
2629 <para><ulink url="#RegisterTemplate">Registering Custom
2630 Templates</ulink></para>
2633 <para><ulink url="#AssignKeyToTemplate">Assigning Keys To
2634 emplates</ulink></para>
2641 <title><anchor id="DefiningTemplate"/>Defining a Template
2642 and Template Insertion Function</title>
2645 <para>The <varname>tempo-define-template</varname> macro
2646 enables you to define a template and a function that
2647 inserts that template at the current point in the current
2648 buffer. You specify the template as a list oftemplate
2649 elements where each element is text, a special symbol, or
2650 a Lisp expression. The function inserts each text element
2651 exactly as specified in the buffer; it replaces special
2652 symbols with some text (e.g., user input), and it replaces
2653 Lisp expressions with the text that results from
2654 evaluating them. </para>
2656 <para>For example, the following Lisp code </para>
2659 (tempo-define-template "foo"
2661 '("System.out.println(\"foo\");")
2662 ;;template definition "f"
2663 ;; abbreviation "Inserts a print foo message")
2664 ;; template documentation
2667 <para>defines a template for Java code that always prints
2668 "foo" to standard out: </para>
2671 System.out.println("foo");
2674 <para>Notice that the template definition uses the Lisp
2675 string escape character to specify the string
2676 "foo". This is necessary when you want to
2677 include quoted strings in a template definition.)
2680 <para>The sample Lisp form also defines an interactive
2681 template function <varname>tempo-template-foo</varname>.
2682 Now suppose you insert the sample code in your
2683 <filename>.emacs</filename> file. After Emacs starts up,
2684 whenever you enter the command <keycombo>
2685 <keycap>M</keycap><keycap>x</keycap></keycombo>
2686 <varname>tempo-template-foo,</varname> Emacs inserts
2690 System.out.println("foo");
2693 <para>at the current point in your Java source buffer (or
2694 any buffer, tempo doesn't care). </para>
2696 <para>The preceding example is admittedly not vary useful
2697 because it always prints the same text. You can create
2698 more useful templates, using special tempo template
2699 symbols and lisp forms. This approach, for example, allows
2700 you to create a template that can print any user-defined
2701 text to standard out: </para>
2704 (tempo-define-template "debug"
2705 ;; template name '("if (debug)" n>
2706 ;; insert new line plus indent
2707 "System.out.println(" (p "Enter debug
2708 message:") ;; Prompts for debug message
2709 ");") "d"
2710 ;; abbreviation "Inserts a print debug message")
2711 ;; template documentation
2714 <para>The template function produced by this example prompts
2715 you to enter the text to be printed when inserting the
2716 function into a buffer. In particular, it inserts </para>
2719 if (debug) System.out.println(DEBUG-MESSAGE);
2722 <para>where <varname>DEBUG-MESSAGE</varname> is any text
2723 that you enter. For example, suppose you enter </para>
2726 "Selected color = " + color
2729 <para>at the prompt. The template function inserts </para>
2732 if (debug) System.out.println("Selected color =
2736 <para>at the current point in the buffer. </para>
2738 <para>See the documentation for
2739 <varname>tempo-define-template</varname> (type
2740 <keycombo><keycap>c</keycap><keycap>h</keycap></keycombo> <keysym>f</keysym>
2741 <varname>tempo-define-template</varname>) for more
2742 information on creating templates. </para>
2749 <title><anchor id="RegisterTemplate"/>Registering Custom
2753 <para>You can register templates that you create with the
2754 JDE. When you register a template with the JDE, it appears
2755 among the list of templates that you can select when you
2757 <guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2758 <guimenuitem>Other....</guimenuitem></menuchoice>. You
2759 register a template by customizing the JDE variable
2760 <varname>jde-gen-code-templates</varname>. The value of
2761 this variable is a list of the template functions that the
2762 JDE command <menuchoice>
2763 <guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2764 <guimenuitem>Other....</guimenuitem></menuchoice> can
2765 invoke. To register a custom template, add its name to the
2766 list. For example, the following screen shows the
2767 customization buffer for
2768 <varname>jde-gen-code-templates</varname> after it has
2769 been customized to include the template defined in the
2770 previous example. </para>
2776 <imagedata fileref="images/RegisterTemplate.gif"/>
2779 <phrase>Screenshot showing customization buffer for
2780 registering templates.</phrase>
2786 <para>To insert a template that you have registered </para>
2789 <step performance="required">
2790 <para>Select <menuchoice>
2791 <guimenu>JDE</guimenu><guisubmenu>Generate</guisubmenu>
2792 <guimenuitem>Other....</guimenuitem></menuchoice></para>
2793 <para>The JDE displays the prompt</para>
2797 <para>in the minibuffer. </para>
2800 <para>Enter the template's name and press
2801 <keycap>Enter</keycap></para>
2803 <para>press the <keycap>Tab</keycap> key to display a
2804 list of templates in a completion buffer: </para>
2809 <imagedata fileref="images/TemplateList.gif"/>
2812 <phrase>Screenshot showing template completion
2818 <para>Select the template you want by double-clicking
2829 <title><anchor id="AssignKeyToTemplate"/>Assigning Keys to
2832 <para>You can assign templates to keyboard keys to speed use
2833 of frequently used templates. For example, insert this
2837 (global-set-key [f9] 'jde-gen-to-string-method)
2840 <para>in your <filename>.emacs</filename> file to assign the
2841 <keycap>F9</keycap> function key to the JDE template that
2842 generates a skeleton <varname>toString</varname> method.
2852 <title><anchor id="CheckStyle"/>Checking Coding Style</title>
2853 <para>The <menuchoice>
2854 <guimenu>JDE</guimenu>
2855 <guimenuitem>Check Style</guimenuitem>
2856 </menuchoice> command (<keycombo>
2859 </keycombo> <command>jde-checkstyle</command>) command checks
2860 the current buffer for conformity to a Java coding standard. The
2861 default standard is that specified by Sun Microsystems. Execute
2862 <command>jde-checkstyle-customize</command> to customize the
2863 command to support your own coding standard.
2865 <para>The command displays a list of stylistic faults in a popup
2866 buffer. Click the error message to display the line that violates
2867 the standard.</para>
2871 <title><anchor id="CompilingJavaPrograms"/>Compiling Java Programs</title>
2873 <para>To compile the source file in the current buffer, select
2875 <guimenuitem>JDE</guimenuitem>
2876 <guimenuitem>Compile</guimenuitem></menuchoice>, type
2880 <keycap>c</keycap></keycombo><keycombo>
2881 <keycap>C</keycap><keycap>v</keycap></keycombo>
2883 <keycap>C</keycap><keycap>c</keycap></keycombo></keycombo>,
2884 or execute <command>M-x jde-compile</command>. The compiler uses
2885 the version of <filename>javac</filename> included in the
2886 currently selected JDK or on your system command path by
2887 default. However, you can configure the JDEE to use another
2888 compiler for the current project or all projects (see <ulink
2889 url="#SpecifyingCompiler">Specifying a Compiler</ulink>). The
2890 JDEE also allows you to configure the JDEE to invoke the
2891 compiler with various <ulink
2892 url="#CompilationOptions">compilation options</ulink>.
2897 <title><anchor id="CompileBuffer"/>Compilation Buffer</title>
2900 The compile command displays the output of the compiler in a
2901 separate compilation buffer.
2907 <imagedata fileref="images/compile_buffer.gif"/>
2910 <phrase>Image showing compilation buffer with
2917 If a compilation buffer exists from a previous compilation, the compile command
2918 reuses the existing buffer; otherwise, it creates a compilation buffer. By default,
2919 if no errors occur in the compilation, the JDEE deletes the compilation buffer
2920 two seconds after the compilation finishes. You can disable this feature by
2921 setting the variable <varname>jde-compile-enable-kill-buffer</varname> off (i.e., to
2926 <title>Compilation Mode</title>
2927 <para>The compilation buffer operates in
2928 <varname>compilation-mode</varname>, a standard Emacs buffer
2929 mode. This mode greatly simplify locating compilation errors
2930 in the Java source code. For example, to find the line that
2931 cause a compilation error, simply click the error message in
2932 the compilation buffer.</para>
2938 <title><anchor id="SpecifyingCompiler"/>Specifying a Compiler</title>
2940 <para>The JDEE supports the following Java compilers.</para>
2944 <para><filename>javac</filename></para>
2946 This is the compiler that comes with Sun's JDK and the
2947 JDK's clones. Note that <filename>javac</filename>
2948 compiler is itself implemented in Java. The
2949 <filename>javac</filename> executable that comes with the
2950 JDK simply starts a vm to run <filename>javac</filename>.
2951 The executable passes its command-line arguments to
2952 <filename>javac</filename>'s main method.
2956 <para>javac compile server</para>
2957 <para>This is a JDEE feature that uses the BeanShell to
2958 invoke the javac compiler on a source file, thus avoiding
2959 the need to start a vm everytime you want to compile
2960 a file. This option greatly reduces the time required
2961 to compile individual files by eliminating the vm startup
2962 time, which is usually much longer than the time required
2963 to compile a file.</para>
2966 <para><filename>jikes</filename></para>
2968 Developed by IBM, this compiler is implemented in
2969 C++ and hence avoids the vm startup time that slows
2978 To specify one of these compilers for the current project or
2984 <para>Type <command>M-x customize-variable</command> and
2985 press <command>Enter</command></para>
2986 <para>Emacs prompts you to enter the name of a variable
2987 to customize.</para>
2990 <para>Enter <varname>jde-compiler</varname> and
2991 press <command>Enter</command>.</para>
2992 <para>The <varname>jde-compiler</varname> customization
2993 buffer appears.</para>
2997 <imagedata fileref="images/spec_compiler.gif"/>
3003 <para>Select the compiler that you want to use for the
3004 current project or all projects.</para>
3006 You can skip the next step if you selected the compile server
3007 or if you selected javac and you want to use the version of
3008 javac that comes with the currently selected JDK, or you have
3009 selected the javac executable or jikes and the executable for
3010 the selected compiler is in your system's command path.
3014 <para>Enter the path to the executable for the selected
3019 <para>If you want your selection to apply only to the current
3020 project, select <command>Save for Current Session</command>
3021 from the <command>State</command> menu. Otherwise select
3022 <command>Save for Future Sessions</command>.</para>
3025 <para>Select <command>Finish</command> to dismiss the
3026 customization buffer.</para>
3029 <para>If you want the selection to apply to the current
3030 project, select <command>Project->Project
3031 File->Save</command> from the <command>JDE</command>
3039 <title><anchor id="CompilationOptions"/>Compilation Options</title>
3041 <para>The JDEE allows you to specify compilation options by
3042 setting compilation variables. You must use the Emacs
3043 customization feature. To use the customization feature,
3045 <guimenu>JDE</guimenu>
3046 <guisubmenu>Options</guisubmenu>
3047 <guimenuitem>Compile</guimenuitem></menuchoice>. (See
3048 <ulink url="#ConfiguringJDE">Configuring the JDEE</ulink> for
3049 more information on using the customization feature). To save
3050 the compilation settings in the project file
3052 url="#UsingProjectFiles">Using Project Files</ulink>)
3053 for the current source buffer, select <menuchoice>
3054 <guimenuitem>JDE</guimenuitem>
3055 <guisubmenu>Options</guisubmenu>
3056 <guimenuitem>Update Project</guimenuitem></menuchoice>.
3062 <title><anchor id="SetCompileOptionsInteractively"/> Setting
3063 Compile Options Interactively</title>
3065 <para>If you set the customization variable
3066 <varname>jde-read-compile-args</varname> to a
3067 non-<varname>nil</varname> value, the JDEE compile command
3068 prompts you to enter compilation options in the minibuffer.
3069 It appends the options that you enter to the options
3070 specified via customization variables. The JDEE saves the
3071 arguments that you enter in a minibuffer history list. You
3072 can recall previously entered options by pressing the up or
3073 down arrows on your keyboard. </para>
3076 <para>The JDEE uses the values of the JDEE customization
3077 variables to set the compiler's command-line option
3078 switches. The JDEE assumes that the compiler you are using
3079 (specified by the customization variable
3080 <varname>jde-compiler</varname>) has the same set of
3081 command-line switches as the version of
3082 <varname>javac</varname> or jikes that you have selected.
3083 If the command-line switch for a particular option
3084 supported by the compiler your are using is not the same
3085 as that specified by <varname>javac</varname> or jikes,
3086 you must use the variable
3087 <varname>jde-compile-option-command-line-args</varname> to
3088 select the option.</para>
3095 <title><anchor id="CompilerCustomizationVariables"/>
3096 Compiler Customization Variables</title>
3098 <para>The following table lists the JDEE compilation variables and
3099 the functions used to set them.</para>
3104 <colspec colnum="1" align="left"/>
3105 <colspec colnum="2" align="left"/>
3106 <colspec colnum="3" align="left"/>
3109 <entry><para>Name</para></entry>
3110 <entry><para>Group</para></entry>
3111 <entry><para>Usage</para></entry>
3114 <tbody valign="top">
3116 <entry><para><varname>jde-compiler</varname></para></entry>
3117 <entry>Project</entry>
3119 <para>Specifies the compiler (javac server, by default)
3120 to use to compile the code in the current source buffer.
3127 <varname>jde-compile-option-command-line-args</varname>
3130 <entry >Compile</entry>
3131 <entry >Specifies a string of
3132 command-line arguments to be passed to the compiler.</entry>
3135 <entry ><varname>jde-global-classpath</varname></entry>
3136 <entry >Project</entry>
3137 <entry >Specify class paths
3138 for compile, run, and debug commands.</entry>
3141 <entry ><varname>jde-read-compile-args</varname></entry>
3142 <entry >Project</entry>
3143 <entry >Specify whether to read compile
3144 options from the minibuffer.</entry>
3147 <entry ><varname>jde-compile-option-classpath</varname></entry>
3148 <entry >Compile </entry>
3149 <entry >Specifies the
3150 classpath for compile command. If set, this variable
3151 overrides <varname>jde-global-classpath</varname>. </entry>
3154 <entry ><varname>jde-compile-option-sourcepath</varname></entry>
3155 <entry >Compile</entry>
3156 <entry >Specifies the path of source files
3157 for classes required to compile the current class.</entry>
3160 <entry ><varname>jde-quote-classpath</varname></entry>
3161 <entry >Project </entry>
3162 <entry >Quote the classpath
3166 <entry ><varname>jde-compile-option-directory</varname></entry>
3167 <entry >Compile </entry>
3168 <entry >Specifies the
3169 directory into which to place the compiled class. </entry>
3172 <entry ><varname>jde-compile-option-deprecation</varname></entry>
3173 <entry >Compile </entry>
3174 <entry >Warn of use or
3175 override of a deprecated member or class </entry>
3178 <entry ><varname>jde-compile-option-debug</varname></entry>
3179 <entry >Compile </entry>
3180 <entry >Generate information
3181 about local variables for debug tools. </entry>
3184 <entry ><varname>jde-compile-option-optimize</varname></entry>
3185 <entry >Compile </entry>
3186 <entry >Directs the compiler
3187 to try to generate faster varname. </entry>
3190 <entry ><varname>jde-compile-option-depend</varname></entry>
3191 <entry >Compile</entry>
3192 <entry >Analyze dependencies.</entry>
3195 <entry ><varname>jde-compile-option-depend-switch</varname></entry>
3196 <entry >Compile</entry>
3197 <entry >Command line switch that causes the
3198 compiler to analyze dependencies.</entry>
3201 <entry ><varname>jde-compile-option-vm-args</varname></entry>
3202 <entry >Compile </entry>
3203 <entry >Specify command-line
3204 arguments for Java interpreter used to run the compiler. </entry>
3207 <entry ><varname>jde-compile-option-verbose-path</varname></entry>
3208 <entry >Compile </entry>
3209 <entry >Print verbose messages.</entry>
3212 <entry ><varname>jde-compile-option-verbose</varname></entry>
3213 <entry >Compile</entry>
3214 <entry >List directories searched to
3215 compile current class.</entry>
3218 <entry ><varname>jde-compile-option-nowarn</varname></entry>
3219 <entry >Compile </entry>
3220 <entry >Turn off warnings.</entry>
3223 <entry ><varname>jde-compile-option-encoding</varname></entry>
3224 <entry >Compile </entry>
3225 <entry >Specify the source
3226 file encoding name, such as EUCJIS\SJIS. </entry>
3229 <entry ><varname>jde-compile-option-target</varname></entry>
3230 <entry >Compile</entry>
3231 <entry >Generate code compatible with a
3232 specified vm version.</entry>
3235 <entry ><varname>jde-compile-option-bootclasspath</varname></entry>
3236 <entry >Compile</entry>
3237 <entry>Specify classpath of standard
3238 libraries for target vm.</entry>
3241 <entry><varname>jde-compile-option-bootclasspath</varname></entry>
3242 <entry>Compile</entry>
3243 <entry>Specify path of directories
3244 containing extensions for target vm.</entry>
3255 <title><anchor id="BuildingJavaApplications"/>Building Java Applications</title>
3257 <para>The <menuchoice>
3258 <guimenu>JDE</guimenu><guimenuitem>Build</guimenuitem></menuchoice>
3259 command builds an application. By default this command invokes the
3260 Unix-style make utility to build the application. You can configure
3261 the build command to invoke the Ant build system or a custom build
3266 <title><anchor id="SelectBuildMethod"/>Selecting a Build Method</title>
3268 <para>To select a build method:</para>
3272 <para>Type <command>M-x customize-variable</command> and
3273 press <command>Enter</command></para>
3274 <para>Emacs prompts you to enter the name of a variable
3275 to customize.</para>
3278 <para>Enter <varname>jde-build-function</varname> and
3279 press <command>Enter</command>.</para>
3280 <para>The <varname>jde-build-function</varname> customization
3281 buffer appears.</para>
3285 <imagedata fileref="images/build_fcn_cust_buff.gif"/>
3291 <para>Select the build function that you want to use.</para>
3294 <para>If you want your selection to apply only to the current
3295 project, select <command>Save for Current Session</command>
3296 from the <command>State</command> menu. Otherwise select
3297 <command>Save for Future Sessions</command>.</para>
3300 <para>Select <command>Finish</command> to dismiss the
3301 customization buffer.</para>
3304 <para>If you want the selection to apply to the current
3305 project, select <command>Project->Project
3306 File->Save</command> from the <command>JDE</command>
3314 <title><anchor id="BuildWithMake"/>Building with Make</title>
3317 The <command>jde-make</command> command uses a make utility,
3318 such as GNU make, to rebuild a project. You must supply the
3319 makefiles used to build your projects. See <ulink
3320 url="#SampleMakefile">Sample Makefile</ulink> for an example
3321 of a makefile for building a Java project. David Ponce's
3323 url="http://perso.wanadoo.fr/david.ponce/">JMaker</ulink>
3324 package generates makefiles automatically for JDEE projects.
3325 It uses JDEE variables to determine classpaths, compiler
3326 options, and other information needed to create projects.
3327 JMaker recursively creates makefiles for all the Java packages
3328 in a project plus a toplevel makefile that invokes the other
3329 makefiles to build the entire project.
3335 <title><anchor id="MakeOptions"/>Make Options</title>
3339 The following customization variables allow you to specify
3340 various <command>jde-make</command> options:
3346 <colspec colnum="1" align="left"/>
3347 <colspec colnum="2" align="left"/>
3348 <colspec colnum="3" align="left"/>
3349 <colspec colnum="4" align="left"/>
3353 <entry>Group</entry>
3354 <entry>Default</entry>
3355 <entry>Usage</entry>
3361 valign="top"><varname>jde-make-program</varname></entry>
3362 <entry valign="top">Project</entry>
3365 <para>Specifies the pathname on your system of the
3366 make utility that the <command>jde-make</command>
3367 uses to build your project. </para>
3372 valign="top"><varname>jde-make-args</varname></entry>
3373 <entry valign="top">Project</entry>
3376 <para> Specifies a string of command-line arguments
3377 (for example, "<varname>-f mymakefile
3378 all</varname>") to be passed to the make
3384 valign="top"><varname>jde-read-make-args</varname></entry>
3385 <entry valign="top">Project</entry>
3386 <entry><varname>nil</varname></entry>
3388 <para> If nonnil, this variable causes the
3389 <command>jde-make</command> command to prompt you
3390 to enter command-line arguments in the minibuffer.
3391 <command>jde-make</command> passes these arguments
3392 along with the arguments specified by
3393 <varname>jde-make-args</varname> to the make
3399 valign="top"><varname>jde-make-working-directory</varname></entry>
3400 <entry valign="top">Project</entry>
3403 <para> Specifies the directory from which
3404 <command>jde-make</command> runs the make utility.
3417 <title><anchor id="SampleMakefile"/>Sample Makefile</title>
3419 <para>The following is a sample makefile that you can use as a
3420 model for creating makefiles to build Java projects. </para>
3423 JDK = d:/jdk1.2/lib/classes.zip
3424 JMATH = d:/jmath/src
3425 CLASSPATH = $(JMATH);$(JDK)
3426 COMPILER = javac VM = java
3427 COPTIONS = -g -deprecation
3429 CLASSES = Test.class \
3431 JMathException.class \
3434 .SUFFIXES: .java .class
3436 # Rebuild (if necessary) and run the JMath test suite. run: $(CLASSES)
3437 $(VM) -classpath "$(CLASSPATH)" jmath.Test
3439 # Remove all class files from the project directory.
3442 # Implicit rule for making Java class files from Java
3444 .java.class: $(COMPILER) $(COPTIONS) -classpath "$(CLASSPATH)" $?
3452 <title><anchor id="BuildWithAnt"/>Building with Ant</title>
3455 The <command>jde-ant-build</command> command uses the <ulink
3456 url="http://jakarta.apache.org/ant/">Apache Ant</ulink>
3457 build tool to build a Java project.
3460 <para>The following variables allow you to control the build
3464 <title>Ant Options</title>
3466 <colspec colnum="1" align="left"/>
3467 <colspec colnum="2" align="left"/>
3468 <colspec colnum="3" align="left"/>
3469 <colspec colnum="4" align="left"/>
3473 <entry>Group</entry>
3474 <entry>Default</entry>
3475 <entry>Usage</entry>
3481 valign="top"><varname>jde-ant-invocation-method</varname></entry>
3482 <entry valign="top">Ant</entry>
3483 <entry>script</entry>
3485 <para> Specifies how to invoke ant. Ant can be invoked
3486 in one of three ways. The first is via the ant
3487 script/program that comes with ant. The second is
3488 via java and the third is via the Ant Server.
3494 valign="top"><varname>jde-ant-home</varname></entry>
3495 <entry valign="top">Ant</entry>
3498 <para> Directory where ant is installed. </para>
3503 valign="top"><varname>jde-ant-user-jar-files</varname></entry>
3504 <entry valign="top">Ant</entry>
3505 <entry><varname>nil</varname></entry>
3507 <para> Specifies jar files that hold user-defined
3513 valign="top"><varname>jde-ant-program</varname></entry>
3514 <entry valign="top">Ant</entry>
3515 <entry><para>ant</para></entry>
3517 <para> Specifies name of ant program/script. </para>
3522 valign="top"><varname>jde-ant-args</varname></entry>
3523 <entry valign="top">Ant</entry>
3524 <entry><para>-emacs</para></entry>
3526 <para> Specifies arguments to be passed to the Ant
3532 valign="top"><varname>jde-ant-buildfile</varname></entry>
3533 <entry valign="top">Ant</entry>
3534 <entry><para>build.xml</para></entry>
3536 <para> Specifies the default buildfile to use. </para>
3541 valign="top"><varname>jde-ant-read-buildfile</varname></entry>
3542 <entry valign="top">Ant</entry>
3543 <entry><para>off</para></entry>
3545 <para> Specify whether to prompt for a buildfile. If
3546 non-nil, the jde-ant-build command prompts you for
3547 an ant buildfile. Note that
3548 <varname>jde-ant-read-buildfile</varname> and
3549 <varname>jde-ant-enable-find</varname> are
3550 incompatible and that
3551 <varname>jde-ant-read-buildfile</varname> will
3552 override the former. </para>
3557 valign="top"><varname>jde-ant-read-target</varname></entry>
3558 <entry valign="top">Ant</entry>
3559 <entry><para>off</para></entry>
3561 <para> Specify whether to prompt for a build target.
3562 If non-nil, the jde-ant-build command prompts you
3563 for an ant target. </para>
3568 valign="top"><varname>jde-ant-interactive-buildfile</varname></entry>
3569 <entry valign="top">Ant</entry>
3570 <entry><para>off</para></entry>
3572 <para> Default buildfile to use when prompting
3573 interactively. </para>
3578 valign="top"><varname>jde-ant-read-args</varname></entry>
3579 <entry valign="top">Ant</entry>
3580 <entry><para>off</para></entry>
3582 <para> Specify whether to prompt for additional
3583 arguments to pass to Ant. If non-nil, the
3584 <command>jde-ant-build</command> command prompts you
3585 for the additional arguments. </para>
3590 valign="top"><varname>jde-ant-enable-find</varname></entry>
3591 <entry valign="top">Ant</entry>
3592 <entry><para>off</para></entry>
3594 <para> Specify whether jde-ant find the
3595 <filename>build.xml</filename> file based on your
3596 current directory. If non-nil, we will search up the
3597 directory hierarchy from the current directory for
3598 the build definition file. Also note that, if
3599 non-nil, this will relax the requirement for an
3600 explicit jde project file. In order for this to
3601 work <varname>jde-ant-read-buildfile</varname> must
3607 valign="top"><varname>jde-ant-complete-target</varname></entry>
3608 <entry valign="top">Ant</entry>
3609 <entry><para>off</para></entry>
3611 <para> Specify whether to enable completion of build
3612 target names in the minibuffer. If non-nil, the
3613 <command>jde-ant-build</command> command allows you
3614 to use tab completion in the minibuffer to specify
3615 the build target name. This list of valid build
3616 targets is determined by parsing the Ant build file.
3617 This option has no effect if
3618 <varname>jde-ant-read-target</varname> is
3624 valign="top"><varname>jde-ant-use-global-classpath</varname></entry>
3625 <entry valign="top">Ant</entry>
3626 <entry><para>off</para></entry>
3628 <para>Specify whether to enable use of
3629 <varname>jde-global-classpath</varname> when running
3630 <filename>jde-ant</filename>.</para>
3635 valign="top"><varname>jde-ant-target-regexp</varname></entry>
3636 <entry valign="top">Ant</entry>
3639 <\s-*target\s-[^...]*?name\s-*=\s-*\"\s-*\([^\"]+\)
3643 <para>Regular expression used to match target names in
3644 Ant build files.</para>
3649 valign="top"><varname>jde-ant-build-hook</varname></entry>
3650 <entry valign="top">Ant</entry>
3651 <entry><para>nil</para></entry>
3653 <para>List of hook functions run by
3654 <command>jde-ant-build</command> (see
3655 <varname>run-hooks</varname> in the Emacs
3656 documentation for more information).</para>
3670 <title><anchor id="RunningJavaApps"/>Running Java
3671 Applications</title>
3674 <para>The JDE allows you to run a Java application as an Emacs
3675 subprocess. You can run multiple applications concurrently, but
3676 only one instance of each application at a time. The JDE
3677 displays each application's standard and error output in an
3678 Emacs command interface (<varname>comint</varname>) buffer. You
3679 can interact with applications that accept command line input
3680 via the <varname>comint</varname> buffer. When interacting with
3681 an application, you can use any of
3682 <varname>comint-mode</varname>'s extensive set of command-line
3683 history commands to speed interaction. To run an application,
3690 <para>or select <menuchoice><guimenu>Java</guimenu>
3691 <guimenuitem>Run App</guimenuitem></menuchoice> from the Emacs
3692 menubar or type <keycombo>
3693 <keycap>C</keycap><keycap>c</keycap></keycombo> <keycombo>
3694 <keycap>C</keycap><keycap>v</keycap></keycombo> <keycombo>
3695 <keycap>C</keycap><keycap>r</keycap></keycombo>. </para>
3698 <title><anchor id="SpecifyingMainClass"/>Specifying the
3699 Application's Main Class</title>
3701 <para>The term <emphasis>main class</emphasis> refers to the
3702 class that contains the application's main method. The JDE's
3703 Run App command assumes by default that the class in the
3704 current buffer is the application's main class. This can be
3705 inconvenient if you have an application that has multiple
3706 classes. You may want to be able to run the application from
3707 any buffer containing one of the application's classes. To do
3708 this, set the variable
3709 <varname>jde-run-application-class</varname> to the
3710 <emphasis>fully qualified name</emphasis> of the application's
3713 <para>You can temporarily override the setting of
3714 <varname>jde-run-application-class</varname> by typing
3715 <varname>C-u -</varname> before executing the <command
3716 moreinfo="none">jde-run</command> command, for example, by
3717 typing <varname>C-u - C-c C-r</varname>. This causes the JDE to
3718 prompt you to enter the <emphasis>fully qualified
3719 name</emphasis> of the application's main class (as well
3720 application arguments if any).</para>
3728 <title><anchor id="SpecifyingStartupDirectory"/>Specifying a
3729 Startup Directory</title>
3731 <para>The JDE can start an application from any directory that
3732 you specify. By default, the JDE starts an application from
3733 the default directory of the current source buffer. The
3734 default directory of the current source buffer is the
3735 directory containing the source file displayed in the buffer.
3736 You can specify another directory as the startup directory by
3737 setting the JDE customization variable
3738 <varname>jde-run-working-directory</varname>.</para>
3740 <para>To set this variable, </para>
3745 <para>Display its customization panel.</para>
3746 <para>You can do this by typing </para>
3748 <keycap>M</keycap><keycap>x</keycap></keycombo> <varname>customize-variable</varname> <varname>jde-run-working-directory</varname></para>
3749 <para>or selecting <menuchoice><guimenu>JDE</guimenu>
3750 <guisubmenu>Options</guisubmenu><guimenuitem>Project</guimenuitem>
3754 </menuchoice> to display the project customization panel
3755 and searching this panel for
3756 <varname>jde-run-working-directory</varname>.
3762 <imagedata fileref="images/WorkingDirectory.gif"/>
3765 <phrase>Screenshow showing customization buffer for
3766 <varname>jde-run-working-directory</varname>.</phrase>
3774 <para>Enter the working directory in the variable's edit
3775 field. </para></step>
3778 <para>Save the new setting.</para>
3779 <para>To save the edited bindings, right click the
3780 <guibutton>[State]</guibutton> button and choose
3782 <guimenuitem>Set for current
3783 session</guimenuitem></menuchoice> if you want the
3784 settings to apply only to the current project or
3786 <guimenuitem>Save for future
3787 sessions</guimenuitem></menuchoice> if you want the
3788 settings to apply to all projects. In either case, you
3789 should save the new settings in you project file if your
3790 project has a project file. To save the new settings in
3791 your project file, switch to a source buffer and choose
3792 <menuchoice><guimenu>JDE</guimenu>
3793 <guisubmenu>Options</guisubmenu><guimenuitem>Save
3794 Project</guimenuitem></menuchoice>.</para>
3804 <title><anchor id="RunVMArgs"/> Setting VM Command-Line
3807 <para>If you set the customization variable
3808 <varname>jde-run-read-vm-args</varname> to a
3809 non-<varname>nil</varname> value, the JDE compile command
3810 prompts you to enter virtual machine options in the
3811 minibuffer. It appends the options that you enter to the
3812 options specified via customization variables. The JDE saves
3813 the arguments that you enter in a minibuffer history list.
3814 You can recall previously entered options by pressing the up
3815 or down arrows on your keyboard. </para>
3822 <title><anchor id="RunAppArgs"/> Setting Command-Line
3823 Application Arguments</title>
3825 <para>Specifying a prefix argument before the
3826 <command>jde-run</command>, e.g., <varname>C-u C-c C-v
3827 C-r</varname> causes the command to prompt you to enter
3828 arguments to be passed to the application's main
3829 method. The command appends the options that you enter to the
3830 arguments specified via the customization variable
3831 <varname>jde-run-option-application-args</varname>. The JDE
3832 saves the arguments that you enter in a minibuffer history
3833 list. You can recall previously entered options by pressing
3834 the up or down arrows on your keyboard. </para>
3836 <para>If you set the customization variable
3837 <varname>jde-run-read-app-args</varname> to a
3838 non-<varname>nil</varname> value, the JDE run command
3839 prompts you to enter command-line application arguments
3840 by default, i.e., you do not have to specify a prefix
3841 argument each time you execute the command.</para>
3845 <title><anchor id="NavigatingExceptionTraces"/>Navigating
3846 Exception Traces</title>
3848 <para>If an exception occurs while your program is running, the
3849 Java vm outputs an exception trace. This trace appears in the
3850 run buffer for the application.</para>
3856 <imagedata fileref="images/excepttrace.gif"/>
3859 <phrase>Screenshot showing an exception trace in the
3860 JDE's run buffer.</phrase>
3867 <para>To view the source line corresponding to a point in the
3868 exception stack trace, right-click the corresponding stack trace
3869 line in the run buffer. You can move up and down the stack trace
3870 by typing the key combinations <varname>C-c C-v C-[</varname> or
3871 <varname>C-c C-v C-]</varname>.</para>
3877 <title><anchor id="RunOptions"/>Run Customization Variables
3880 <para>The JDE allows you to specify run-time options by setting
3881 run variables.You can use the Emacs customization feature to
3882 set run-time variables interactively. To use the customization
3885 <guimenu>JDE</guimenu><guisubmenu>Project</guisubmenu><guisubmenu>Options</guisubmenu><guimenuitem>Run</guimenuitem></menuchoice>.
3886 (See <ulink url="#ConfiguringJDE">Configuring the JDE</ulink>
3887 for more information on using the customization feature). To
3888 save the compilation settings in the project file (see <ulink
3889 url="#UsingProjectFiles">Using Project Files</ulink>) for
3890 the current source buffer, select <menuchoice>
3891 <guimenu>JDE</guimenu>
3892 <guisubmenu> Project</guisubmenu><guisubmenu>Project
3893 File</guisubmenu><guimenuitem>Save
3894 Project</guimenuitem></menuchoice>.
3897 <para>The following table lists the JDE run variables and the
3898 functions used to set them. </para>
3903 <colspec colnum="1"/>
3904 <colspec colnum="2"/>
3905 <colspec colnum="3"/>
3908 <entry>Variable</entry>
3909 <entry>Group</entry>
3910 <entry>Usage</entry>
3916 valign="top"><varname>jde-run-mode-hook</varname></entry>
3917 <entry valign="top">Project</entry>
3918 <entry valign="top">List of hook functions run by
3919 <varname>jde-run-mode</varname></entry>
3923 valign="top"><varname>jde-run-working-directory</varname></entry>
3924 <entry valign="top">Project</entry>
3925 <entry>Startup directory for running or debugging Java
3926 applications.</entry>
3930 valign="top"><varname>jde-run-application-class</varname></entry>
3931 <entry valign="top">Project </entry>
3932 <entry valign="top">Name of the Java class to run. The
3933 command <varname>jde-run-set-app</varname> sets the
3934 buffer-local value of this variable. </entry>
3938 valign="top"><varname>jde-run-java-vm</varname></entry>
3939 <entry valign="top">Project </entry>
3940 <entry valign="top">Specify Java interpreter for
3941 non-Windows platforms. The command
3942 <varname>jde-run-set-vm</varname> sets the
3943 buffer-local value of this variable. </entry>
3947 valign="top"><varname>jde-run-java-vm-w</varname></entry>
3948 <entry valign="top">Project </entry>
3949 <entry valign="top">Specify Java interpreter for Windows
3950 platforms. The command
3951 <varname>jde-run-set-vm-w</varname> sets the
3952 buffer-local value of this variable. </entry>
3956 valign="top"><varname>jde-global-classpath</varname></entry>
3957 <entry valign="top">Project </entry>
3958 <entry valign="top">Specify class paths for compile,
3959 run, and debug commands. The command<varname>
3960 jde-set-global-classpath</varname> sets the
3961 buffer-local value of this variable. </entry>
3965 valign="top"><varname>jde-run-classic-mode-vm</varname></entry>
3966 <entry valign="top">Project</entry>
3967 <entry>Specifies that the JDE should run the JDK's
3968 classic version of the Java virtual machine (as
3969 opposed to the HotSpot version). This option applies
3970 only to versions of the JDK that include both a
3971 classic and a HotSpot vm.</entry>
3975 valign="top"><varname>jde-run-read-vm-args</varname></entry>
3976 <entry valign="top">Project</entry>
3977 <entry>Specifies whether to read vm arguments from
3978 the minibuffer.</entry>
3982 valign="top"><varname>jde-run-option-classpath</varname></entry>
3983 <entry valign="top">Run </entry>
3984 <entry valign="top">Specifies the classpath for
3985 the Java interpreter. This option overrides the
3986 jde-global-classpath option. </entry>
3990 valign="top"><varname>jde-run-option-verbose</varname></entry>
3991 <entry valign="top">Run </entry>
3992 <entry valign="top">Print messages about the running
3993 process. </entry>
3997 valign="top"><varname>jde-run-option-properties</varname></entry>
3998 <entry valign="top">Run </entry>
3999 <entry valign="top">Specify property values.</entry>
4003 valign="top"><varname>jde-run-option-heap-size</varname></entry>
4004 <entry valign="top">Run </entry>
4005 <entry valign="top">Specify the initial and maximum size
4006 of the interpreter heap. </entry>
4010 valign="top"><varname>jde-run-option-stack-size</varname></entry>
4011 <entry valign="top">Run </entry>
4012 <entry valign="top">Specify size of the C and Java
4017 valign="top"><varname>jde-run-option-garbage-</varname>
4018 <varname>collection</varname> </entry>
4019 <entry valign="top">Run</entry>
4020 <entry valign="top">Specify garbage collection
4021 options. </entry>
4025 valign="top"><varname>jde-run-option-java-profile</varname></entry>
4026 <entry valign="top">Run </entry>
4027 <entry valign="top">Enable Java profiling.</entry>
4031 valign="top"><varname>jde-run-option-heap-profile</varname></entry>
4032 <entry valign="top">Run </entry>
4033 <entry valign="top">Output heap profiling data.</entry>
4037 valign="top"><varname>jde-run-option-verify</varname></entry>
4038 <entry valign="top">Run </entry>
4039 <entry valign="top">Verify classes.</entry>
4043 valign="top"><varname>jde-run-option-vm-args</varname></entry>
4044 <entry valign="top">Run </entry>
4045 <entry valign="top">Specify command-line arguments to be
4046 passed to the Java vm. The command jde-run-set-args
4047 sets the buffer-local value of this
4048 variable. </entry>
4052 valign="top"><varname>jde-run-option-application-args</varname></entry>
4053 <entry valign="top">Run </entry>
4054 <entry valign="top">Specify command-line arguments to
4055 pass to the application. The command
4056 <varname>jde-run-set-app-args </varname>sets the
4057 buffer-local value of this variable. </entry>
4070 <title><anchor id="WorkingWithApplets"/> Working with Applets</title>
4072 <para>The JDE provides specialized commands for running and
4073 debugging applets.</para>
4078 <title><anchor id="RunningApplets"/>Running Applets</title>
4080 <para>To run an applet:</para>
4085 <para>Open the applet's source file in a buffer. </para>
4089 <para>Choose <menuchoice>
4090 <guimenu>JDE</guimenu><guimenuitem>Run
4091 Applet</guimenuitem>
4092 </menuchoice>. </para>
4093 <para>The JDE searches for an html file in the directory
4094 containing the applet source file and displays the first
4095 file it finds, using your system's default browser. If
4096 the JDE cannot find an html page in the applet's source
4097 file directory, it signals an error by default.
4103 <para>The <menuchoice><guimenu>JDE</guimenu>
4104 <guimenuitem>Run Applet</guimenuitem></menuchoice> command
4105 assumes by default that the directory containing the applet's
4106 source also contains an html page for testing that applet. If
4107 this is not true in your case, you have two options. You can
4108 either specify the path of the applet file via the JDE
4109 customization variable <varname>jde-run-applet-doc</varname>
4110 or you can use the <varname>jde-run-applet</varname> command
4111 to run your applet. If the
4112 <varname>jde-run-applet-doc</varname> variable is not a null
4113 string, <menuchoice><guimenu>JDE</guimenu>
4114 <guimenuitem>Run Applet</guimenuitem></menuchoice> displays
4116 document that the variable specifies instead of searching the source
4117 file directory for a document to display. The
4118 <varname>jde-run-applet</varname> command prompts you to enter in the
4119 minibuffer the path of an html file to display. If you enter nothing,
4120 the command defaults to the behavior of <menuchoice><guimenu>JDE</guimenu>
4121 <guimenuitem>Run Applet</guimenuitem></menuchoice>.</para>
4123 <para>The run commands chooses the viewer as follows. If
4124 <varname>jde-run-applet-viewer</varname> is a null string (the
4125 default) or browse-url, the JDE uses browse-url to launch the
4126 applet doc in your system's default browser. Otherwise, the
4127 menu command uses comint to launch the viewer (e.g.,
4128 appletviewer) specified by
4129 <varname>jde-run-applet-viewer</varname>.</para>
4135 <title><anchor id="DebuggingApplets"/>Debugging Applets</title>
4137 <para>To debug an applet:</para>
4142 <para>Open the applet's source file in a buffer.</para>
4146 <para>Choose <menuchoice><guimenu>JDE</guimenu>
4148 Applet</guimenuitem></menuchoice>.</para>
4149 <para>The JDE searches for an html file in the directory
4150 containing the applet source file. If the JDE cannot find
4151 an html page in the applet's source file directory, it
4152 signals an error by default. Otherwise, it runs
4153 appletviewer in debug mode on the first file that it
4155 <para>The Emacs window splits into two panes.</para>
4159 <para>The top pane shows the applet's source file with the debug
4160 cursor pointing to the first line of the applet's init file.
4161 The bottom pane displays the debugger's command line
4162 interface. You can now set breakpoints, single-step, or
4163 continue running the applet. See <ulink
4164 url="#DebuggingApps">Debugging Applications</ulink> for more
4167 <para>If you want to specify the document to be used to test the
4168 applet, customize the variable jde-run-applet-doc or execute
4169 <varname>M-x jde-db-applet</varname>. This command prompts you
4170 to enter the test document's name.</para>
4176 <title><anchor id="AppletOptions"/>Applet Customization
4179 <para>The JDE allows you to specify run-time options for applets
4180 by setting JDE configuration variables.You must use the Emacs
4181 customization feature to set applet run-time variables . To
4182 use the customization feature, select <menuchoice>
4183 <guimenu>JDE</guimenu><guisubmenu>Options</guisubmenu><guimenuitem>Run</guimenuitem></menuchoice>.
4184 (See <ulink url="#ConfiguringJDE">Configuring the JDE</ulink>
4185 for more information on using the customization feature). In
4186 some cases, the JDE also provides functions for setting the
4187 buffer-local values of the compilation variables. To save the
4188 compilation settings in the project file (see <ulink
4189 url="#UsingProjectFiles">Using Project Files</ulink>) for
4190 the current source buffer, select
4191 <menuchoice><guimenu>JDE</guimenu><guisubmenu>Options</guisubmenu><guimenuitem>Update
4192 Project</guimenuitem></menuchoice>. </para>
4194 <para>The following table lists the JDE applet run-time
4195 variables and the functions used to set them. </para>
4202 <entry>Variable</entry>
4203 <entry>Group</entry>
4204 <entry>Usage</entry>
4210 valign="top"><varname>jde-run-applet-viewer</varname></entry>
4211 <entry valign="top">Project </entry>
4212 <entry valign="top">Specify name of viewer to use to
4213 display page containing the applet. The command
4214 <varname>jde-run-set-applet-viewer</varname> sets the
4215 buffer-local value of this variable. </entry>
4219 valign="top"><varname>jde-run-applet-doc</varname></entry>
4220 <entry valign="top">Project </entry>
4221 <entry valign="top">Specify name of document containing
4222 applet to be viewed. The command
4223 <varname>jde-run-set-applet-doc</varname> sets the
4224 buffer-local value of this variable. </entry>
4236 <title><anchor id="DebuggingApps"/>Debugging Applications</title>
4238 <para>The JDE provides two options for debugging Java applications.</para>
4242 <para>An Emacs interface to <command>jdb</command>, the command-line
4243 debugger that comes with the JDK. See <ulink url="../jdb-ug/jdb-ug-frame.html"
4244 type="jdb-ug">Debugging with jdb</ulink> for more
4245 information. </para>
4250 JDEbug, a Java debugger developed specifically for use with the JDE.
4251 See <ulink url="../jdebug-ug/jdebug-ug.html" type="jdebug-ug">JDEbug
4252 User's Guide</ulink> for more information</para>.
4256 <para>JDEbug provides more debugging features but requires a JDK 1.2
4257 or higher vm. You must use <command>jdb</command> to debug applications
4258 running on earlier vms.</para>
4265 <title><anchor id="SpecifyingClasspaths"/>Specifying
4268 <para>The JDE provides customization variables that permit you to
4269 specify a classpath for the JDE's compile, run, debug,
4270 Beanshell, and other commands. The following table lists these
4274 <title>Classpath Variables</title>
4278 <entry>Variable</entry>
4279 <entry>Applies To ...</entry>
4284 <entry><para><varname>jde-global-classpath</varname></para></entry>
4285 <entry><para>All JDE commands that use a
4286 classpath.</para></entry>
4289 <entry><para><varname>jde-compile-option-classpath</varname></para></entry>
4290 <entry><para>Compile command</para></entry>
4293 <entry><para><varname>jde-run-option-classpath</varname></para></entry>
4294 <entry><para>Run App command</para></entry>
4297 <entry><para><varname>jde-db-option-classpath</varname></para></entry>
4298 <entry><para>Debug App command</para></entry>
4304 <para>The <varname>jde-global-classpath</varname> variable is so
4305 named because it specifies a classpath that is used by all JDE
4306 commands unless overridden by a classpath variable specific to a
4307 particular command. For example, the JDE's
4308 <command>Compile</command> command uses
4309 <varname>jde-global-classpath</varname> unless the value of
4310 <varname>jde-compile-option-classpath</varname> is set.
4311 Typically you want to use the same classpath to compile, run,
4312 and debug an application. So typically
4313 <varname>jde-global-classpath</varname> is the only variable you
4319 <title><anchor id="SettingClasspathVar"/>Setting a Classpath
4321 <para>As with other JDE customization variables, you must use
4322 Emacs' <command moreinfo="none">customize-variable</command>
4323 command to set the JDE's classpath variables. You can use
4324 relative paths, cygwin paths, and paths with tilde notation
4325 and environment variables as values of JDE classpath
4326 variables. See <ulink url="#SpecifyingPaths">Specifying
4327 Paths</ulink> for more information.
4331 When setting a classpath variable, you must enter each path as
4332 a separate entry in the customization buffer. Do not enter the
4333 paths as semicolon or colon-separated lists of paths. The
4334 following examples show the right and wrong way to specify a
4338 <title>Wrong Way to Specify a Classpath</title>
4339 <programlisting format="linespecific">
4340 jde-global-classpath: [Hide]
4341 [INS] [DEL] Path: c:/jde-dev/jmath/classes;c:/jde-dev/jmath/src
4343 [State]: this option has been set and saved.
4348 <title>Right Way to Specify a Classpath</title>
4349 <programlisting format="linespecific">
4350 jde-global-classpath: [Hide]
4351 [INS] [DEL] Path: c:/jde-dev/jmath/classes
4352 [INS] [DEL] Path: c:/jde-dev/jmath/src
4354 [State]: this option has been set and saved.
4360 <title><anchor id="ClassLibraries"/>Including Class
4363 If you store your class libraries as jar or zip files in
4364 separate directory, you need specify only the path of the
4365 directory in a JDE classpath variable. Whenever the JDE
4366 encounters a library directory in a classpath variable, it
4367 expands the classpath to include all the jar and zip files in
4368 the library directory.
4372 For example, suppose you organize your project directory as
4376 <para> <programlisting format="linespecific"> myproj classes lib
4377 src </programlisting>
4381 where the <filename>src</filename> directory contains all of
4382 your source files, the <filename>lib</filename> directory all
4383 of your jar and zip files, and the
4384 <filename>classes</filename> directory all of the classes
4385 compiled from the <filename>src</filename> directory. Further,
4386 suppose you store your project file (see <ulink
4387 url="#UsingProjectFiles">Using Project Files</ulink>) at the
4388 root of your project directory. Then, you can specify
4389 <varname>jde-global-classpath</varname> simply as follows.
4393 <programlisting format="linespecific"> jde-global-classpath:
4394 [Hide] [INS] [DEL] Path: ./classes [INS] [DEL] Path: ./src
4395 [INS] [DEL] Path: ./lib [INS] [State]: this option has been
4396 set and saved. </programlisting>
4400 If you do not want the JDE to expand library directories, set
4401 the variable <varname>jde-expand-classpath-p</varname> off.
4402 The JDE expands directories whose names match the regular
4403 expressions specified by
4404 <varname>jde-lib-directory-names</varname>. The default values
4405 of this variable are <filename>^lib</filename> and
4406 <filename>^jar</filename>. So by default, the JDE expands
4407 names that begin with the string <filename>lib</filename> or
4408 <filename>lib</filename>, e.g., <filename>lib</filename>,
4409 <filename>libraries</filename>, etc. However, you can
4410 customize <varname>jde-lib-directory-names</varname> to
4411 reflect any library naming scheme you prefer.
4422 <title><anchor id="UsingProjectFiles"/>Using Project Files</title>
4424 <para>A project file is a Lisp file that the JDEE loads and
4425 evaluates whenever you open a Java source file belonging to a
4426 specific project. The JDEE has commands that save the current
4427 settings of JDEE project variables in the project file for the
4428 current project. Project files thus allow you to save and
4429 restore project-specific settings of JDEE customization
4430 variables. For example, you can use a project file to set the
4431 value of the <varname>jde-global-classpath</varname> variable to
4432 a project-specific classpath automatically whenever you load a
4433 file belonging to that project. </para>
4438 <title><anchor id="FindingProjectFiles"/>How the JDE Finds Project Files</title>
4440 <para>To simplify the task of finding project files, the JDE makes
4441 two assumptions. First, it assumes that all Java source files
4442 relating to a particular project live in a single directory tree.
4443 Second, it assumes that all project files have the same file name.
4444 The name assumed by default is <filename>prj.el</filename>. You can use the JDE
4445 configuration variable <varname>jde-project-file-name</varname> to specify
4446 another name.</para>
4449 When you open a Java source file, the JDE looks for
4450 project files in the directory tree containing the source file.
4451 If the JDE finds one or more project files, it loads the
4452 project files in the following manner.
4456 The JDE first sets all the JDE variables to their
4457 Emacs startup values (i.e., the default value or the value
4458 saved in your <filename>.emacs</filename> file). It then loads
4459 all the project files in the directory tree containing the
4460 current source buffer, starting with the topmost file.
4464 What this means is that you can use project files to extend
4465 and/or override the settings in your
4466 <filename>.emacs</filename> file and in other project files.
4467 For example, your <filename>.emacs</filename> file can specify
4468 settings that are common to all your projects. You can put
4469 settings common to a group of projects at the top of the
4470 directory tree containing the projects, settings common to
4471 each project at the top of the directory containing each
4472 projects, and so on.
4480 <title><anchor id="ProjectFileContents"/> Project File
4484 <para>A project file can contain any Lisp code that can be
4485 evaluated correctly as the last step in creating a Java source
4486 buffer. For example, a project file can contain code that sets
4487 the value of JDE configuration variables. In general, a
4488 project file can contain any code that could be implemented
4489 as a <varname>jde-mode</varname> hook function. In fact, you
4490 can think of a project file as a project-specific
4491 <varname>jde-mode</varname> hook function. </para>
4497 <title><anchor id="CreatingProjectFiles"/>Creating a Project
4500 <para>The easiest way to create a project file is to use the
4501 <varname>jde-create-new-project </varname> command (<menuchoice>
4502 <guimenu>JDE</guimenu>
4503 <guisubmenu>Project</guisubmenu><guisubmenu>Project
4504 File</guisubmenu><guimenuitem>Create
4505 New</guimenuitem></menuchoice>). This command creates a
4506 new project file and saves the
4507 current values of all customized JDE configuration variables
4508 in the project file for the selected Java buffer. (To be
4509 precise, the command inserts Lisp code in the project file
4510 that restores the current settings of the configuration
4511 variables; if such code already exists in the file, it
4512 replaces it with updated code.) Thus, to create
4513 a project file that sets JDE configuration variables to
4514 project-specific values:
4519 <para>Open any source file belonging to the project.</para>
4522 <para>Set the values of the JDE configuration variables to
4523 the appropriate values for the project to which the source
4524 file belongs.</para>
4527 <para>See <ulink url="#ConfiguringJDE">Configuring the
4528 JDE</ulink> for information on how to set the values of
4529 the JDE configuration variables.</para>
4532 <para>Select <menuchoice>
4533 <guimenu>JDE</guimenu>
4534 <guisubmenu>Project</guisubmenu><guisubmenu>Project
4535 File</guisubmenu><guimenuitem>Save
4536 Project</guimenuitem></menuchoice>.
4539 <step performance="required">
4540 <para> The JDE prompts you to enter the path to a directory
4541 in which to store the project file.
4544 <step performance="required">
4546 Enter the directory where you want to store the project
4547 file or press <keycap>Enter</keycap> to store the project
4548 file in the current directory.
4553 <para>Once you have created the project file, you can insert
4554 additional configuration code into the file if desired. Note
4555 that the <varname>jde-save-project</varname> command edits
4556 rather than replaces existing project files. Thus, you can use
4557 the command to update configuration variable settings without
4558 disturbing any other configuration code that you have inserted
4559 manually into the project file.
4564 <title><anchor id="CreatingPortableProjects"/>Creating Portable Projects</title>
4566 You can use relative paths and environment variables to
4567 construct portable project files. For example, suppose your
4568 project directory has the following structure:
4583 Further suppose that your project uses beans from a
4584 shared library specified by the environment variable
4585 <varname>BEANS</varname>. With this setup,
4586 you can specify <varname>jde-global-classpath</varname> as
4592 $BEANS/lib/dials.jar
4596 and <varname>jde-compile-option-directory</varname> as
4604 This causes the JDE to store classes compiled from your src
4605 directory in the classes directory. Note that you have not
4606 used any absolute paths in creating your project file. This
4607 means you can move your project anywhere without having to update
4614 <title><anchor id="DisablingContextSwitching"/>Disabling Context Switching</title>
4615 <para>When you select a buffer that belongs to another
4616 project, the JDE loads the project file for that project
4617 and may update the class list for the project. This
4618 causes a slight delay before you can begin using the
4619 new buffer. The delay can be irritating if you need
4620 to switch frequently among open projects, for example,
4621 when copying or diffing code from different projects.
4622 Accordingly, the JDE provides ways for you to disable
4623 context-switching either permanently or temporarily.
4626 <para>To disable context-switching permanently, toggle
4627 the customizat variable
4628 <varname>jde-project-context-switching-enabled-p</varname>
4629 off. Be sure to use customize to do this and save the
4630 customization in your <filename moreinfo="none">
4631 .emacs</filename> or <filename moreinfo="none">prj.el</filename>
4632 file. Note that you can use the JDE's project file loading
4633 command, <command>JDE->Project->Project File->Load</command>,
4634 to switch contexts manually.
4638 To disable context-switching temporarily during a session,
4640 JDE->Project->Auto Switch</command> or enter
4641 <varname>M-x jde-toggle-project-context-switching</varname>. To reenable
4642 context-switching, execute the same command again.
4647 <title><anchor id="ProjectHooks"/>Project Hook Functions</title>
4648 <para>The variable <varname>jde-project-hooks</varname> lists
4649 functions that execute after the JDEE loads a project file. By
4650 writing hook functions and adding them to this list, you can
4651 specify actions to be taken every time the JDEE switches from
4652 one project to another.</para>
4660 <title><anchor id="DisplayingDoc"/> Displaying Java Documentation</title>
4664 The JDE provides commands for displaying the JDK API documentation
4665 and context-sensitive help for classes.
4671 <title><anchor id="BrowsingJDKDoc"/> Browsing JDK
4672 Documentation</title>
4675 <para>The <varname>jde-browse-jdk-doc</varname> command
4677 <guimenu>JDE</guimenu><guimenuitem>Help</guimenuitem>
4678 <guimenuitem>JDK</guimenuitem></menuchoice>, <keycombo>
4679 <keycap>C</keycap><keycap>c</keycap></keycombo>
4681 <keycap>C</keycap><keycap>v</keycap></keycombo> <keycombo>
4682 <keycap>C</keycap><keycap>n</keycap></keycombo>) opens the
4683 JDK documentation in a browser. By default, this command
4684 displays the JDK documentation page at JavaSoft's web site. To
4685 display a different copy, set the variable
4686 <varname>jde-jdk-doc-url</varname> to the url of the index
4687 page of the copy you want to be displayed. </para>
4693 <title><anchor id="ClassHelp"/> Context-Sensitive Class
4697 <para>The JDK provides context-sensitive help for Java classes.
4698 To use this facility, you must first customize the variable
4699 <varname>jde-help-docsets</varname> to specify the location of
4700 class documentation on your system. The JDE class help
4701 facility supports javadoc documentation by default but it
4702 works with other types of documentation as well.</para>
4704 <para>Once you have specified the location of class
4705 documentation on your system, you can get help for the class
4706 at point in the current buffer by selecting <menuchoice>
4707 <guimenu>JDE</guimenu><guisubmenu>Help</guisubmenu><guimenuitem>Symbol
4708 at Point</guimenuitem></menuchoice> . </para>
4712 <title><anchor id="Specifying a Browser"/>Specifying a Browser</title>
4713 <para>The JDEE uses the browsers or browsers specified by the customization
4714 variable <varname>browse-url-browser-function</varname>. See the documentation
4715 for this variable for more information.</para>
4718 <title><anchor id="UsingEmacs-w3m"/>Using emacs-w3m to Browse Java Doc</title>
4719 <para>The <filename>emacs-w3m</filename> package uses the
4720 <filename>w3m</filename> text-mode HTML browser to enable
4721 Emacs to render text HTML pages. This allows you to use
4722 Emacs not only to develop Java code but also to browse Java
4723 API and tools documentation. For information on downloading
4724 and installing emacs-w3m and w3m, see the <ulink
4725 url="http://emacs-w3m.namazu.org/">emacs-w3m</ulink> web
4728 <para>While you're at it, you should also install the <ulink
4729 url="http://www.emacswiki.org/cgi-bin/wiki/WThreeM">
4730 WThreeM</ulink> package. This package provides
4731 incremental searching on URLs in w3m HTML buffers, a nice feature
4732 for browsing Javadoc class documentation, with its wealth of
4735 <para>One you have installed <filename>emacs-w3m/w3m</filename>, you can
4736 configure Emacs (and hence the JDEE) to use it to display Javadoc pages
4737 by customizing <varname>jde-help-browser-function</varname> to specify
4738 <filename>w3m-browse-url</filename>. </para>
4741 <para>The <filename>w3m-browse-url</filename> function displays its output
4742 by default in the current window, replacing the Java file in the buffer.
4743 To cause the function to display its output in a popup window, customize
4744 <varname>w3m-pop-up-frames</varname>.</para>
4753 <title><anchor id="BrowsingSourceCode"/>Browsing Source Code</title>
4755 <para>The JDE provides the following facilities for browsing Java source code:</para>
4759 <para><ulink url="#ClassesMenu">Classes index menu</ulink></para>
4762 <para><ulink url="#Speedbar">Speedbar</ulink></para></listitem>
4764 <para><ulink url="#Tags">Etags</ulink></para></listitem>
4771 <title><anchor id="ClassesMenu"/> Classes Index Menu</title>
4774 <para>The <menuchoice><guimenu>Classes</guimenu></menuchoice>
4775 index menu appears by default in the Emacs menubar whenever a
4776 Java source buffer is active. The menu consists of a cascading
4777 list of all classes, methods, fields, and imports defined in
4778 the current buffer plus the package to which the current
4779 buffer belongs. Selecting any item scrolls the buffer to the
4780 statement that defines the item.</para>
4785 <imagedata fileref="images/classes_menu1.gif"/>
4788 <phrase>Screenshot showing Classes menu.</phrase>
4793 <para>The top-level menu contains an entry for each each class
4794 defined by the active buffer followed by entries for the
4795 imports and package of the current buffer. Selecting the entry
4796 for a class displays a submenu listing the inner classes,
4797 methods, and fields defined by the class. Selecting the entry
4798 for an inner class displays another submenu for that class,
4799 and so on. Selecting the
4800 <menuchoice><guimenu>imports</guimenu></menuchoice> entry on
4801 the top-level menu displays a submenu listing all the classes
4802 and packages imported by the active buffer.</para>
4807 <title><anchor id="SpecialIndexEntries"/> Special Index
4810 <para>The index menu includes the following special index
4816 <para><menuchoice><guimenu>*Rescan*</guimenu></menuchoice></para>
4817 <para>Selecting this item causes the JDE to rebuild the
4818 index menu. You should rebuild the menu whenever you
4824 <para><menuchoice><guimenu>*class
4825 def*</guimenu></menuchoice></para>
4826 <para>Selecting this item takes you to the start of the
4827 definition of the class on whose submenu it appears.
4829 <varname>jde-imenu-include-classdef</varname> off to
4830 suppress inclusion of these items in the menu. </para>
4839 <title><anchor id="AlphabetClassesMenu"/>Alphabetizing the
4840 Classes Menu</title>
4842 <para>By default the
4843 <menuchoice><guimenu>Classes</guimenu></menuchoice> menu
4844 lists methods and fields in the order in which the active
4845 buffer defines them. Use the variable
4846 <varname>jde-imenu-sort</varname> to customize the menu to
4847 list methods and fields alphabetically in either ascending
4848 or descending order.</para>
4854 <title><anchor id="SuppressingSignatures"/>Suppressing Method
4855 Signatures and Field Types</title>
4857 <para>By default the
4858 <menuchoice><guimenu>Classes</guimenu></menuchoice> menu
4859 displays the signatures of methods and the types of fields
4860 displayed in the active buffer. The method signatures enable
4861 you to distinguish overloaded method names. The menu can
4862 also display the names of methods and fields without
4863 signatures and types. Use the variable
4864 <varname>jde-imenu-include-signature</varname> to turn
4865 signature and type display off or on. </para>
4870 <title><anchor id="DisablingClassesMenu"/>Disabling the
4871 Classes Menu</title>
4874 <para>Set the variable <varname>jde-imenu-enable</varname> off
4876 <menuchoice><guimenu>Classes</guimenu></menuchoice> menu.
4877 When disabled, the menu does not appear in the Emacs
4882 <title>Using the Keyboard to Navigate the Classes Menu</title>
4884 Execute <command>M-x imenu</command> to use the keyboard
4885 to navigate the Classes menu. Emacs displays the
4886 top-level items on the Classes menu in a buffer and
4887 prompts you to enter the name of an an item in the
4888 minibuffer. Enter the name of the item to select it.
4889 Note that you can use completion to avoid having to
4890 type the whole name. If you select a submenu, Emacs
4891 displays the contents of the submenu and prompts
4892 you to enter a selection in the keyboard. If you
4893 select an index entry, Emacs scrolls the buffer
4894 to the indexed point in the buffer.
4903 <title><anchor id="Speedbar"/>Using the Speedbar</title>
4905 <para>To display the speedbar, select <menuchoice>
4906 <guimenu>JDE</guimenu>
4907 <guimenuitem>Browse</guimenuitem>
4908 <guimenuitem>Source Files</guimenuitem></menuchoice>. The
4909 speedbar opens in a separate frame.</para>
4914 <imagedata fileref="images/speedbar1.gif"/>
4917 <phrase>Screenshot showing the speedbar.</phrase>
4923 <para>The speedbar displays a list of the files and
4924 subdirectories in the directory containing the file displayed
4925 in the current buffer. The speedbar highlights the file
4926 displayed in the current buffer.</para>
4928 <para>Click on the expand (+) button in front of any file. The
4929 node for the file expands</para>
4935 <imagedata fileref="images/speedbar2.gif"/>
4938 <phrase>Screenshot showing a speedbar entry.</phrase>
4944 <para>to show up to three entries, depending on the contents of
4945 the source file. </para>
4949 <title><anchor id="Package"/>Package</title>
4952 This item expands to show the package to which the file
4959 <imagedata fileref="images/speedbar3.gif"/>
4962 <phrase>Screenshot showing a speedbar entry.</phrase>
4969 Clicking on the package scrolls the buffer to the
4970 corresponding package declaration.
4977 <title><anchor id="Types"/>Types</title>
4980 This item expands to show the classes in the selected file.
4986 <imagedata fileref="images/speedbar4.gif"/>
4989 <phrase>Screenshot showing a speedbar entry.</phrase>
4996 Each class expands to show the constructors, methods,
4997 fields, and inner classes defined by the class and the
4998 class's parent, if any. Inner classes also expand and their
4999 inner classes, and so on. The constructors and methods
5000 expand to show arguments and argument types and return
5001 types. Fields expand to show their type.
5005 Clicking on any class, inner class, method, constructor, or
5006 field scrolls the buffer to show that item.
5013 <title><anchor id="Dependencies"/>Dependencies</title>
5015 This item expands to show the classes and packages imported by the current source file.
5020 <imagedata fileref="images/speedbar5.gif"/>
5023 <phrase>Screenshot showing a speedbar entry.</phrase>
5029 <para>Click on class or package to scroll the buffer to the
5030 corresponding import statement.</para>
5036 <title><anchor id="UpdatingSpeedbar"/>Updating the
5039 <para>If you make changes to a source buffer, you must update
5040 the speedbar view to reflect the changes. To update the
5041 speedbar view of a buffer:</para>
5046 Collapse the speedbar view of the buffer.
5049 This is necessary only if the speedbar view is expanded.
5050 To collapse the speedbar view, click the collapse button
5051 (-) next to the buffer's file name in the speedbar view.
5055 <para>Hold the shift key down while clicking the expand
5056 button (+) next to the buffer's name in the speedbar
5066 <title><anchor id="SearchSource"/>Searching Source Code</title>
5068 <para>The JDEE provides commands that enable you to find</para>
5073 All occurences of strings matching a regular expression anywhere
5074 in your project's source path (see <ulink url="#FindExpressions">Finding
5075 Expressions</ulink>)
5080 Source code that defines the method, field,
5081 or other symbol at point (see <ulink url="#FindSymbolDef">Finding
5082 Symbol Definitions</ulink>)
5086 <para>Source code for the class at point (see <ulink url="#FindClasses">Finding
5087 Classes</ulink>)</para>
5090 <para>Source for the parent of the class at point</para>
5093 <para>Source for an interface implemented by the class at point</para>
5096 <para>All methods that invoke a specifed method (see <ulink url="#Xref">Cross-Referencing
5097 Classes</ulink>)</para>
5102 <title><anchor id="FindExpressions"/>Finding Expressions</title>
5103 <para>The JDEE provides two commands for finding occurrences of strings
5104 in Java source and other types of text files:</para>
5108 <para><command>JDE->Find->Expression</command>
5109 (<function>jde-find</function>)</para>
5111 This command uses the minibuffer to prompt you for the
5112 search expression and the paths to be searched. You can
5113 use customization variables to specify values for the
5114 search paths and other search options. The default values
5115 for the customization variables search the Java source
5116 files on the classpaths and sourcepaths for your project.
5117 See <ulink url="#FindExpressionMinibuf">Using the Minibuffer-Based
5118 Find Command</ulink> for more information.
5122 <para><command>JDE->Find->Expression...</command>
5123 (<function>jde-find-dlg</function>)</para>
5124 <para>This command uses a text dialog buffer to
5125 prompt you for search arguments. The dialog buffer
5126 allows you to specify all search options
5127 interactively. It is thus useful for performing
5128 searches that have special requirements.
5129 See <ulink url="#FindExpressionDlg">Using the Dialog-Based
5130 Find Command</ulink> for more information. </para>
5135 Both commands use the Unix <command>grep</command> and
5136 <command>find</command> utilities to perform the searches that
5137 you specify. Before executing a search, both commands search
5138 your system for copies of <command>grep</command> and
5139 <command>find</command> and signal an error if the utilities
5140 are missing. All Unix systems include copies of
5141 <command>grep</command> and <command>find</command>. Versions
5142 of these utilities are available for Microsoft Windows, e.g.,
5143 as part of the Cygwin Unix emulation package for Microsoft
5144 Windows. If you want to use the JDEE's <command>find</command>
5145 commands on Windows, you must install copies of
5146 <command>grep</command> and <command>find</command> on your
5147 system and either include them in your system's command path
5148 or use the variables <varname>grep-command</varname> and
5149 <varname>find-program</varname> to specify their respective
5150 locations on your system.
5155 Microsoft Windows/NT and Windows 2000 provide a
5156 <command>find</command> utility that is incompatible with
5157 the Unix <command>find</command> utility. To ensure that the
5158 JDEE finds the right version, you should either put the
5159 Unix-style <command>find</command> command ahead of the
5160 Windows <command>find</command> command in your system
5161 command path or use the <varname>find-program</varname>
5162 variable to specify the Unix-style command's location.
5167 <title><anchor id="FindExpressionMinibuf"/>Using the
5168 Minibuffer-Based Find (jde-find) Command</title>
5170 <para>To find an expression with the minibuffer-based find
5180 <keysym>C-c</keysym>
5181 <keysym>C-v</keysym>
5182 <keysym>C-f</keysym>
5185 <guimenu>Find</guimenu>
5186 <guimenuitem>Expression</guimenuitem>
5188 from the <guimenu>JDE</guimenu> menu
5189 or execute the <command>jde-find</command> command.
5191 <para>The JDEE prompts you to enter a regular expression.</para>
5195 <imagedata fileref="images/find_minibuf_prompt_regex.gif"/>
5198 <phrase>Screenshot showing the regular expression prompt.</phrase>
5204 <para>Enter a regular expression that matches the
5205 expressions you want to find and press <keycap>Enter</keycap>.</para>
5206 <para>The JDEE prompts you to enter a list of directories to search.</para>
5210 <imagedata fileref="images/find_minibuf_prompt_dirs.gif"/>
5213 <phrase>Screenshot showing the directories prompt.</phrase>
5217 <para>The prompt may list a default search path. The JDEE determines the
5218 default path by testing each of the following variables in the order
5222 <para><varname>jde-sourcepath</varname></para>
5225 <para><varname>jde-compile-option-sourcepath</varname></para>
5228 <para><varname>jde-compile-option-classpath</varname></para>
5231 <para><varname>jde-global-classpath</varname></para>
5234 <para>The JDEE uses the directories
5235 specified by the first path variable that has a nonnil
5236 value as the default search path.</para>
5239 <para>Edit the default search path, if desired, in the minibuffer
5240 and press <keycap>Enter</keycap>.</para>
5241 <para>The JDEE executes the find command that you have specified
5242 and displays the command's output in a popup grep-mode buffer.</para>
5246 <imagedata fileref="images/find_minibuf_result.gif"/>
5249 <phrase>Screenshot showing the search results.</phrase>
5256 <para>The search results buffer lists each instance of a string
5257 that matches the specified regular expression in the specified
5258 search path. For each match, the listing shows the file
5259 and line number of the match, highlighted in red, and a snippet
5260 of the text in which the match occurred.
5262 <para>To visit the file containing the match, click the
5263 match message in the grep buffer with the middle mouse button
5264 or move point to the message and press <keycap>Enter</keycap></para>
5268 <title><anchor id="FindExpressionCustomize"/>Customizing the
5269 Minibuffer-Based Find Command</title>
5271 The following variables allow you to customize the
5272 minibuffer-based search command:
5279 <entry>Variable</entry>
5280 <entry>Default Value</entry>
5281 <entry>Description</entry>
5286 <entry><varname>jde-find-case-sensitive</varname></entry>
5287 <entry><literal>nil</literal></entry>
5288 <entry>Specifies whether the <command>jde-find</command> command
5289 performs a case-sensitive search. If non-nil, the
5290 search is case-sensitive; otherwise the search
5291 ignores case.</entry>
5294 <entry><varname>jde-find-granularity</varname></entry>
5295 <entry><literal>Character</literal></entry>
5296 <entry>Specifies the granularity of the expression
5297 search conducted by <command>jde-find</command>: <literal>Character</literal>
5298 (expression starting on any character), <literal>Word</literal> (match
5299 words only), <literal>Line</literal> (match lines only).</entry>
5302 <entry><varname>jde-find-file-regexp</varname></entry>
5303 <entry><literal>*.java</literal></entry>
5304 <entry>Specifies the regular expression that the
5305 <command>jde-find</command> command uses to select
5306 files to be searched. You can use any regular
5307 expression supported by the <literal>-name</literal>
5308 option of the GNU <command>find</command>
5317 <title><anchor id="FindExpressionDlg"/>Using the Dialog-Based Find (jde-find-dlg) Command</title>
5319 <para>To find an expression with the dialog-based find command:</para>
5326 <guimenu>Find</guimenu>
5327 <guimenuitem>Expression...</guimenuitem>
5329 from the <guimenu>JDE</guimenu> menu
5330 or execute the <command>jde-find</command> command.
5333 <para>The <guilabel>Find Expression Options</guilabel> buffer appears.</para>
5338 <imagedata fileref="images/find_options_buffer.gif"/>
5341 <phrase>Screenshot showing the Find Expression Options buffer.</phrase>
5348 <para>Edit the buffer to reflect the search options that you desire.</para>
5350 <para>The options you select will appear the
5351 next time you execute the <command>jde-find-dlg</command> command.</para>
5355 <para>Select the <guibutton>Ok</guibutton> button.</para>
5359 <para>The <command>jde-find-dlg</command> invokes the
5360 <command>find</command> and <command>grep</command> commands
5361 with the options you specified and displays the results in a
5369 <title><anchor id="FindSymbolDef"/>Finding Symbol Definitions</title>
5370 <para>To find the source code that defines the class, interface,
5371 method, or field at point, select
5374 <keycombo><keysym>C</keysym><keysym>c</keysym></keycombo>
5375 <keycombo><keysym>C</keysym>
5376 <keysym>v</keysym></keycombo>
5377 <keycombo><keysym>C</keysym><keysym>y</keysym></keycombo>
5379 <guimenu>Find</guimenu>
5380 <guimenuitem>Symbol Definition</guimenuitem>
5381 </menuchoice> from the <guimenu>JDE</guimenu> menu or
5383 <keysym>M</keysym><keysym>x</keysym></keycombo>
5384 <function>jde-open-class-at-point</function>. The JDEE
5385 displays a buffer containing the source code that defines the
5386 symbol at point in the original buffer.</para>
5389 <para>This command requires that the symbol definition be
5390 located on <varname>jde-sourcepath</varname> and that the
5391 class referenced at point be located on
5392 <varname>jde-global-classpath</varname>. The command uses
5393 the beanshell to determine the fully qualified name of the
5394 class referenced at point. If the beanshell is not running,
5395 it launches the beanshell.</para>
5403 <title><anchor id="FindClasses"/>Finding Classes</title>
5405 <para>The <function>jde-open-class-source</function> command
5406 finds and opens the Java source file for the class whose
5407 qualified or unqualified name appears at point.</para>
5410 <para>The JDE uses Java reflection to determine the fully
5411 qualified name of the class at point. Therefore, the class
5412 must be on <varname>jde-global-classpath</varname>.</para>
5415 <para>If more than one class with the same name exists on
5416 <varname>jde-global-classpath</varname>, this command prompts
5417 you to select one of the classes. The following conditions
5418 must be true for this command to work. First, a class file for
5419 this class must exist on the classpath specified by
5420 <varname>jde-global-classpath</varname>. Secondly, the source
5421 for the class must exist on one of the paths specified by
5422 <varname>jde-sourcepath</varname>. This command uses the
5423 Beanshell to determine the fully qualified name of the class
5424 to be found. It starts the Beanshell if necessary. Thus, the
5425 command may respond somewhat slowly the first time you it in a
5432 <title><anchor id="Xref"/>Cross-Referencing Classes</title>
5435 <para>JDE includes a facility for creating and utilizing a
5436 cross-referencing database to enable you to quickly locate all
5437 the callers of any particular function. This functionality is
5438 very useful for quickly figuring how unfamiliar code works,
5439 and useful for doing certain tasks such as renaming functions.
5440 Be advised that this only finds direct callers, and cannot
5441 detect calls via Java's reflection mechanism. The
5442 cross-reference database must be kept in sync with the project
5443 code, however the database generation is generally quick. The
5444 remainder of this section explains how to configure and use
5445 the cross-referencer.</para>
5447 <note>The JDEE's cross-referencing facility was developed by Andrew Hyatt.</note>
5451 <title><anchor id="ConfigXRef"/>Configuring the Cross-Referencer</title>
5453 <para>JDE's cross-referencing database is built by examining
5454 class files for a particular project. To this end, JDE
5455 needs to know where the built class files for a project
5456 live. This is usually a subset of the classpath.
5459 <para>Then select JDE->Options->Project->General, and go to
5460 the "Jde Built Class Path" option. Insert one path for each
5461 place where built classes wind up. You can add both
5462 directories and zip files (jar/bar/etc). Any file entered
5463 will be assumed to be a zip file.</para>
5465 <para>Now that you have the built class path defined, you can
5466 configure the cross-referencer that uses it. Type M-x
5467 jde-xref-customize. The following are a list the variables
5468 that can be set, and what they do:
5473 <para><varname>jde-xref-db-base-directory</varname></para>
5475 <para>The cross-referencer creates a database to
5476 store the cross-reference information. This variable
5477 defines a directory where that information resides. It
5478 might, for example, be at the base of your project tree,
5479 in a directory called xrefdb
5484 <para><varname>jde-xref-store-prefixes</varname></para>
5486 <para>To reduce database size,
5487 it's useful to ignore all information that doesn't refer
5488 to code you care about. For example, most people don't
5489 need to know who calls java.lang.System.out.println. To
5490 not store this information, insert a package prefix for
5491 each package you are interested in. Typically, this may
5492 be just one string, for example "com.mycompany", to
5493 store only code that references com.mycompany
5498 <para><varname>jde-xref-cache-size</varname></para>
5499 <para>The caller database can be quite large. However, it
5500 is useful for efficiency reasons to keep part of it in
5501 memory. This variable deterines how many packages to
5502 keep in memory simulatenously. The higher this is, the
5503 faster things will be, but also the more memory will be
5504 taken up by the cross-reference information.
5513 <title><anchor id="BuildingXRefDB"/>Building the Cross-Reference Database</title>
5516 <para>The next step into getting the cross-reference
5517 functionality working is to build the cross-reference
5518 database. The project must be fully built for this to work,
5519 since it takes cross-reference information directly from the
5523 <para>To build the database, type <command>M-x jde-xref-make-xref-db</command></para>
5525 <para>If all the settings are properly configured, JDE will go
5526 off and create the cross-reference database. This can take
5527 from a few seconds to several minutes depending on the size
5528 of your project. Large class files may take long to parse,
5529 so if it seems to be "stuck", please give it time.
5532 <para>When it is done, it will save the database in the base
5533 directory specified in the jde-xref customization group.
5540 <title><anchor id="UsingXRefDB"/>Using the Cross-Reference Database</title>
5543 <para>There are several basic operations that use the
5544 cross-reference database:
5552 <para><command>M-x jde-xref-first-caller (C-c C-v a)</command>
5555 <para> If your cursor is in the body of a function, then
5556 this will go to the first in a sequence of callers to
5557 this function. If there are no callers, there will be a
5565 <para><command>M-x jde-xref-next-caller (C-c C-v n)</command></para>
5567 <para> After calling <command>jde-xref-first-caller</command>, you can go to
5568 each of the callers in sequence with this function. The
5569 first caller function creates a list of callers and goes
5570 to the first one. This navigates to the next caller on
5571 the list. You can keep calling this until there are no
5572 more callers, in which case there will be a message
5578 <para><command>M-x jde-xref-display-call-tree</command>
5581 <para>This displays an interactive tree view of the
5582 function you are in, and it's callers. Each level down
5583 will show you who calls the parent function. In this
5584 way you can quickly get an overview of the context in
5585 which the current function is used in. Each item in the
5586 tree will take you to it's definition if it is clicked
5592 <para><command>M-x jde-xref-list-uncalled-functions</command></para>
5594 <para> Called from a java file, this lists all the
5595 functions in the file that have no apparent callers.
5596 It's important to remember that because of Java
5597 reflection, there is no guarantee that the functions are
5598 truly uncalled. It only means they are not called
5605 <para>All of these functions have two modes, a strict and
5606 non-strict mode. In non-strict mode, the default, more
5607 potential callers are treated as callers, including those
5608 that call an interface that the function implements, or who
5609 call a superclass's function you are overriding. For
5610 example, if you are in Foo.doSomething(), and foo implements
5611 IFoo, and a caller calls IFoo.doSomething(), then this is
5612 treated as a caller in non-strict mode. Also, if you are in
5613 Foo.doSomething, and Foo's superclass is Bar, and there is a
5614 Bar.doSomething(), then Bar.doSomething() is treated as a
5615 caller in non-strict mode. In strict mode, however, the
5616 caller must specify the function directly for it to be
5617 considered a hit. To run these functions with strict mode,
5618 type C-u M-x and then the function-name. So C-u M-x
5619 jde-xref-list-uncalled-functions will list only functions
5620 that are uncalled directly.
5628 <title><anchor id="UpdatingXRefDB"/>Updating the Cross-Reference Database</title>
5631 <para>As the code changes, the cross-referencer must be kept
5632 up to date, or else the jde-xref functions will start taking
5633 you to incorrect places in files, and the callers list
5634 itself will become incorrect. As you change the code, you
5635 can call M-x jde-xref-update after a recompile, and it will
5636 go through and recompute just the part of the database you
5640 <para>Another, easier way to update, for those of us who leave
5641 their emacs running all the time, is to add a line such as
5642 this in their .emacs
5646 (run-at-time "11:00pm" 86400 'jde-xref-make-xref-db)
5658 <title><anchor id="Tags"/>Tags</title>
5660 <para>To use the <varname>etags</varname> facility, you must
5661 first construct a TAGS file that indexes every symbol in your
5662 source code. The JDE package contains two shell scripts that
5663 you can use to tag your source code, one for
5664 <command>csh</command> shells and the other for
5665 <command>bash</command>. The <command>bash</command> version
5666 is called <command>jtags</command>; the <command>csh</command>
5667 version, <command>jtags.csh</command>. </para>
5672 <title><anchor id="TaggingCode"/> Tagging Java Source Code</title>
5676 <para>To tag your source code, first copy the appropriate shell
5677 script to a directory in your Emacs path. Then start a shell (<keycombo>
5678 <keycap>M</keycap><keycap>x</keycap> </keycombo>
5679 shell). Change to the top-level directory containing your
5680 source code and then enter <command>jtags</command>. The <command>jtags</command>
5681 script tags every <filename>.java</filename> file in the current directory
5682 and in all descendants of the current directory, storing the
5683 result in a file called <filename>TAGS</filename> in the top-level directory.
5690 <title><anchor id="FindingSymbols"/>Finding the Definition of a Symbol</title>
5693 <para>To find the definition of a symbol, put your cursor anywhere
5694 in the symbol and enter
5695 <keycombo><keycap>M</keycap><keycap>.</keycap></keycombo>. Emacs
5696 responds by locating
5697 and opening (if necessary) the file containing the definition and
5698 positioning the point at the definition. (The first time you type
5699 <keycombo><keycap>M</keycap><keycap>.</keycap></keycombo>, Emacs
5700 prompts you to load the <filename>TAGS</filename> file.) </para>
5710 <title><anchor id="CustomizingJDE"/>Customizing the JDE</title>
5714 This section describes various ways you can customize the JDE.
5720 <title><anchor id="CustomizationVariables"/>Customization Variables</title>
5723 JDE customization variables allow you to specify compile, run, debug,
5724 and other JDE options. </para>
5727 <para> The traditional way of customizing Emacs is to use
5728 <varname>setq</varname> forms to set the values of customization
5729 variables in the Emacs initialization (<filename>.emacs</filename>)
5730 file. This method does <emphasis>not</emphasis> work for JDE
5731 customization variables. To set a JDE customization variable, you
5732 <emphasis>must</emphasis> use the customization buffer for a variable
5733 (see the Emacs online manual for information on the customization
5734 feature). This is because the JDE context switching code resets all
5735 JDE customization variables to their default or customized (via a
5736 custom buffer) values whenever you open a Java source file or switch
5741 <para> The following section explains how to use the Emacs
5742 customization feature to set the value of a JDE customization
5748 <title><anchor id="SettingVariable"/> Setting a Customization Variable</title>
5752 To set a JDE customization variable:
5757 <para>Determine the name of the variable you want to customize.</para>
5758 <para> Refer to the section of this guide that documents the feature
5759 you want to customize for the name of the corresponding variable. Or
5760 type <keycombo><keycap>C</keycap><keycap>h</keycap></keycombo>
5761 <keysym>v</keysym> followed by the JDE group prefix
5762 (<varname>jde-</varname>) or subgroup prefix (e.g.,
5763 <varname>jde-compile-option-</varname>,
5764 see <ulink url="#JDECustomizationGroups">JDE Customization Groups</ulink>).
5765 Emacs displays all variables belonging to the JDE group or subgroup. You
5766 can then browse this list, using Emacs search, completion, and
5767 documentation display command, to find the applicable variable.
5772 <para>Display a customization buffer for the variable. </para>
5773 <para> If you know the name of the variable, the easiest way to
5774 display a customization buffer for the variable is to select
5775 <menuchoice><guimenu>Help</guimenu><guisubmenu>Customize</guisubmenu>
5776 <guimenuitem>Specific Option...</guimenuitem></menuchoice> from the
5777 Emacs menubar or type <keycombo><keycap>M</keycap><keycap>x</keycap>
5778 </keycombo> <command>jde-customize-variable</command>.</para>
5781 <para><command>jde-customize-variable</command> is a
5782 special version of the standard Emacs
5783 <command>customize-variable</command> command that
5784 provides a customization buffer menu item for saving a
5785 customization in a JDEE project file (see below). You
5786 should use this version of the command if you intend
5787 to save customizations in project files. You can also
5788 use it to do any other type of customization that the
5789 standard command supports. This allows you to use the
5790 JDEE version of the command for all your
5791 customizations regardless of whether you intend to
5792 save them in project files. </para>
5796 If you know the group to which the variable belongs (.e.g., compile
5797 options), you can display the customization buffer for the group. This
5798 is useful when you want to customize several related variables. See
5799 <ulink url="#JDECustomizationGroups">JDE Customization Groups</ulink> for
5805 <para>Edit the value for the variable displayed in the customization
5810 <para>Save the value for the variable in your <filename>.emacs</filename>
5811 or <filename>.prj</filename> file.
5813 <para>If you want the setting to apply to all projects that do not
5814 have a project file (see <ulink url="#UsingProjectFiles">Using Project
5815 Files</ulink>), you should save the variable in your
5816 <filename>.emacs</filename> file. To save the variable in your
5817 <filename>.emacs</filename> file, select <menuchoice><guimenuitem>Save
5818 for Future Sessions</guimenuitem></menuchoice> from the
5819 <menuchoice><guimenu>State</guimenu></menuchoice> menu for the
5820 variable in the customization buffer.
5822 <para> If you want the setting to apply only to the current project,
5824 <menuchoice><guimenuitem>Save in JDEE Project File</guimenuitem>
5825 </menuchoice> from the <menuchoice><guimenu>State</guimenu>
5826 </menuchoice> menu for the variable.
5831 The <menuchoice><guimenuitem>Save in JDEE Project File</guimenuitem>
5832 </menuchoice> menu item appears only if you used the
5833 <command>jde-customize-variable</command> command to create
5834 the customization buffer.
5839 If a project file does not exist for the project, the
5840 JDEE prompts you to enter a name for the project.
5841 It then creates a project file for the project with
5842 the name that you enter.
5851 <title><anchor id="SpecifyingPaths"/>Specifying Paths</title>
5852 <para>You can use paths containing environment variables and
5853 or a tilde (~), cygwin paths, and relative paths as a value
5854 of any JDE customization variable that requires a
5858 <title><anchor id="EnvVarsInPaths"/>Environment Variables</title>
5859 <para>The JDE accepts paths that contain envirnoment variables, for
5863 <programlisting format="linespecific">
5869 The JDE replaces the environment variables with their
5870 actual values before passing the paths to commands (e.g.,
5871 javac) that require them. You must use Unix notation
5872 (i.e., <varname>$VARNAME</varname> or
5873 <varname>${VARNAME}</varname>) to specify an environment
5874 variable in a path even on Windows.
5880 <title><anchor id="TildeNotation"/>Tilde (~) Notation</title>
5881 <para>The JDE accepts paths that begin with a tilde, for example,
5882 <filename>~/myproj/classes</filename>. The JDE replaces the tilde
5883 with the path to your home directory.</para>
5887 <title><anchor id="RelativePaths"/>Relative Paths</title>
5888 <para>A relative path is a path that begins with a period, for
5889 example, <filename>./src</filename>. If
5890 <varname>jde-resolve-relative-paths</varname> is
5891 set to a non-nil value (the default), the JDE converts a relative
5892 path to an absolute path by appending the relative path to the
5893 path of the project file that set the path variable, or if no such
5894 file exists, to the path of the current Java source buffer.</para>
5897 You can use your <filename>.emacs</filename> file to
5898 specify default relative paths for projects. For example,
5899 setting <varname>jde-global-classpath</varname> to
5900 <filename>./classes</filename> in your
5901 <filename>.emacs</filename> file specifies that the
5902 default location of class files is in a subdirectory of
5903 the project file directory named <filename>classes</filename>.
5908 <title><anchor id="CygwinPaths"/>Cygwin Paths</title>
5909 <para>You can use cygwin style paths in JDE classpath variables
5910 on Windows. The JDE converts such paths to DOS paths before
5911 using them, using a conversion function that you can specify.</para>
5913 <para>The jde-cgywin-path-converter variable allows you
5914 to choose the path conversion function used by the JDE.</para>
5918 <para><function moreinfo="none">
5919 jde-cygwin-path-converter-internal</function></para>
5920 <para>This is the default path conversion function used by
5921 the JDE. It converts any paths of the form <varname>//[a-z]/</varname>
5922 or <varname>//cygdrive/[a-z]/</varname> to the corresponding DOS form. For
5923 example it converts <varname>/c/jde/java/classes</varname> to
5924 <varname>c:/jde/java/classes</varname>.
5928 <para><function moreinfo="none">jde-cygwin-path-converter-cygpath</function></para>
5929 <para>This function invokes the cygwin
5930 <function>cygpath</function> utility to perform the
5931 path conversion. The advantage is that the cygwin path
5932 utility can recognize and convert Unix style paths
5933 that represent mount points in the cygwin mount table.
5934 For example, suppose that you have mounted
5935 <varname>d:/javadev</varname> as
5936 <varname>/javadev</varname> in the cygwin mount table.
5937 Then choosing <function
5938 moreinfo="none">jde-cygwin-path-converter-cygpath</function>
5939 allows you to use paths beginning with
5940 <varname>/javadev</varname> in JDE classpaths. The
5941 drawback is that the conversion is slow as it requires
5942 running the cygwin utility for each Unix-style path to
5943 be converted.</para>
5946 <para>A custom conversion function that you supply.</para>
5957 <title><anchor id="JDECustomizationGroups"/> JDE Customization Groups</title>
5960 <para>The JDE defines a top-level customization group, the JDE
5961 Group, for JDE customization variables. The JDE Group itself
5962 contains the following subgroups:</para>
5968 <title><anchor id="CompileOptionGroup"/> Compile Option
5972 <para>Specifies compile options corresponding to the
5973 command-line arguments (e.g., -d) accepted by the JDK
5974 compiler, javac. When you execute the JDE compile command,
5975 the JDE uses the settings of this group to construct a list
5976 of command-line arguments that it passes to the Java
5977 compiler that the JDE uses to compile Java source programs.
5978 The compiler is itself an option that you can specify (see
5979 the Project Option Group). You can specify command-line
5980 arguments directly by setting the value of the
5981 <varname>jde-compile-option-command-line-args</varname>
5982 variable. You can display the customization buffer for the
5983 Compile Option Group by selecting
5984 <menuchoice><guimenu>JDE</guimenu><guisubmenu>
5985 Project</guisubmenu>-<guisubmenu>Options</guisubmenu>
5986 <guimenuitem>Compile</guimenuitem></menuchoice> from the
5987 <productname>Emacs</productname> menubar. </para>
5993 <title><anchor id="CompileOptionGroup"/>Run Option Group</title>
5996 <para>Specifies run-time options corresponding to the
5997 command-line arguments (for example, -classpath) accepted
5998 by the JDK virtual machine, java. When you execute the JDE
5999 Run command, the JDE uses the settings of this group
6000 to construct a list of command-line arguments that it
6001 passes to the Java interpreter used by the JDE to run
6002 applications. This group also contains options for
6003 specifying non-java command-line arguments (in case you
6004 want to use a VM that accepts a different set of arguments
6005 than java does) and for specifying arguments to be passed
6006 to the application (as opposed to the virtual machine
6007 interpreting the application.) You can display the
6008 customization buffer for the Run Option Group by selecting
6009 <menuchoice><guimenu>JDE</guimenu>
6010 <guisubmenu>Project</guisubmenu>-<guisubmenu>Options</guisubmenu>
6011 <guimenuitem>Run</guimenuitem></menuchoice> from the
6012 <productname>Emacs</productname> menubar. </para>
6017 <title><anchor id="DebugOptionGroup"/>Debug Option Group</title>
6019 <para>Specifies run-time options corresponding to the command-line
6020 arguments (for example, -classpath) accepted by the JDK debugger,
6021 jdb. jdb accepts the same command-line arguments as java. However,
6022 the JDE maintains two parallel sets of configuration variables
6023 for these programs in case you want to use a different set of
6024 options for running a program in debug mode then you use for
6025 running it normally. When you execute the JDE Debug command,
6026 the JDE uses the settings of this group to construct a list of
6027 command-line arguments that it passes to the Java debugger used
6028 by the JDE to run applications in debug mode. You can display the
6029 customization buffer for the Debug Option Group by selecting
6030 <menuchoice><guimenu>JDE</guimenu>
6031 <guisubmenu>Project</guisubmenu>-<guisubmenu>Options</guisubmenu>
6032 <guimenuitem>Debug</guimenuitem></menuchoice>
6033 from the <productname>Emacs</productname> menubar. </para>
6039 <title> <anchor id="AutocodeGroup"/>Autocode Group</title>
6042 <para>Specifies templates used to generate code automatically. </para>
6048 <title><anchor id="GeneralGroup"/> General Options Group</title>
6051 <para>Specify all other JDE options. You can display the
6052 customization buffer for the General Option Group by selecting
6053 <menuchoice><guimenu>JDE</guimenu>
6054 <guisubmenu>Project</guisubmenu>-<guisubmenu>Options</guisubmenu>
6055 <guimenuitem>General</guimenuitem></menuchoice>
6056 from the <productname>Emacs</productname> menubar. </para>
6065 <title><anchor id="Customizingjde_mode"/> Customizing jde-mode</title>
6068 <para>The JDE defines a major mode, named jde-mode, for editing
6069 Java source files. This mode derives from the standard Emacs
6070 Java source editing mode java-mode. In particular, it inherits
6071 all the functions and customization variables defined by
6072 java-mode and adds its own customization variables. When you
6073 load a Java source file, Emacs runs a JDE mode initialization
6074 function called jde-mode. The jde-mode function in turn calls
6075 the Java mode intialization function, java-mode. The last
6076 thing that jde-mode does before returning is to call a JDE
6077 mode function, if it exists. You can customize the JDE by
6078 defining a JDE mode hook function in your .emacs file. The
6079 following is an example of how to do this: </para>
6083 (defun my-jde-mode-hook ()
6084 (message "my-jde-mode-hook function executed"))
6085 (add-hook 'jde-mode-hook 'my-jde-mode-hook)
6088 <para>The preceding example defines a JDE mode hook function named
6089 my-jde-mode-hook and adds it to the list of JDE mode hook
6090 functions, using the Emacs Lisp function add-hook. Now, whenever
6091 you open a Java source file, jde-mode invokes the function my-jde-mode-hook.
6092 Of course, the hook function defined in this example is trivial.
6093 A real-world example might do something more useful, such as
6094 setting a custom indentation style. </para>
6100 <title><anchor id="Keybindings"/> Customizing Key Bindings</title>
6103 <para>A key binding establishes an equivalence between a keystroke
6104 or a sequence of keystrokes and an interactive Lisp function. The
6105 keystroke or keystroke combination causes Emacs to execute the
6106 function to which the keystroke (combination) is bound. For
6107 example, the JDE by default binds the keystroke <keycombo><keycap>C</keycap><keycap>c</keycap></keycombo> <keycombo><keycap>C</keycap><keycap>v</keycap></keycombo> <keycombo><keycap>C</keycap><keycap>c</keycap></keycombo>
6108 to the function <varname>jde-compile</varname>. You can use the JDE
6109 customization facility to change the standard JDE bindings or
6110 create bindings for functions that do not have default bindings. </para>
6112 <para>To customize key bindings: </para>
6116 <para>Open a buffer on the JDE customization variable <varname>jde-key-bindings</varname>.</para>
6117 <para>You can do this by typing
6118 <keycombo><keycap>M</keycap><keycap>x</keycap>
6119 </keycombo> <varname>customize-variable</varname>
6120 <varname>jde-key-bindings</varname> or by selecting <menuchoice>
6121 <guimenu>JDE</guimenu><guisubmenu>Options</guisubmenu><guimenuitem>Project</guimenuitem></menuchoice> and searching the
6122 resulting JDE project customization buffer for
6123 <varname>jde-key-bindings</varname>. </para>
6124 <para>The key bindings panel looks like this: </para>
6129 <imagedata fileref="images/keybindings.gif"/>
6132 <phrase>Screenshot showing key bindings buffer.</phrase>
6140 <para>Edit the buffer to specify altered or new bindings. </para>
6141 <para>For example, to add a binding, right click the
6142 <guibutton>[INS]</guibutton> button, then enter the key stroke in the
6143 <guilabel>Key</guilabel> field and the interactive function (command)
6144 to which it is bound in the <guilabel>Command</guilabel> field.</para>
6148 <para>Save the edited bindings. </para>
6149 <para>To save the edited bindings, right click the
6150 <guibutton>[State]</guibutton> button and choose <menuchoice>
6151 <guimenuitem>Set for current session</guimenuitem></menuchoice> if you
6152 want the settings to apply only to the current project or
6153 <menuchoice><guimenuitem>Save for future
6154 sessions</guimenuitem></menuchoice>if you want the settings to apply
6155 to all projects. In either case, you should save the new settings in
6156 you project file if your project has a project file. To save the new
6157 settings in your project file, switch to a source buffer and choose
6158 <menuchoice><guimenu>JDE</guimenu><guisubmenu> Options</guisubmenu><guimenuitem>Save Project</guimenuitem></menuchoice> from the Emacs menubar.
6168 <title><anchor id="Plugins"/>Creating and Installing Plugins</title>
6170 <para>Plugins are independently developed applications intended
6171 for use with the JDEE and distributed in the form of a (g)zip or
6172 jar file. The following sections explain how to create and install
6178 <title><anchor id="InstallingPlugins"/>Installing a Plugin</title>
6180 <para>To install a plugin:</para>
6184 <para>Copy the zip or jar file containing the plugin in to
6185 the JDEE's plugins directory.</para>
6188 <para>By default the JDEE plugin directory is a
6189 subdirectory of the JDEE directory named
6190 <filename>plugins</filename>. If you want to keep your
6191 plugins in another directory, set
6192 <varname>jde-plugins-directory</varname> to the path of
6193 that directory.</para>
6200 <para>Execute <command>M-h jde-pi-install-plugins</command>.</para>
6201 <para>This command installs any plugins at the top level of the plugins
6202 directory in the plugins directory.</para>
6208 <para>If the plugin adds any menu items to the JDEE's plugins menu
6209 (named <guimenu>JDEpi</guimenu>), you should now be able to see the
6210 items on the plugins menu.</para>
6216 <title><anchor id="CreatingPlugins"/>Creating a Plugin</title>
6218 <para>The following sections explain how to create a JDEE plugin.</para>
6222 <title><anchor id="PluginRequirements"/>Plugin Requirements</title>
6224 <para>A JDEE plugin must meet the following requirements:</para>
6228 <title>Packaging</title>
6230 <para>The plugin must be distributed as a compressed file that can be
6231 decompressed by Java's jar program. Compressed file formats that meet this
6232 requirement include zip, gzip, and jar.
6239 <title>Directory Structure</title>
6241 <para>Decompressing the plugin should create a subdirectory in the
6242 current directory whose name is the plugin's name and that contains
6243 at least one directory named <filename>lisp</filename>. The
6244 plugin directory can contain any number of other directories.
6245 The other directories can have any names. However, it would be
6246 nice if plugins standardized on the following directory structure
6259 src (e.g., xml files used to generate info and html)
6263 lib (e.g, jar files)
6273 <title>Bootstrap File</title>
6275 <para>The plugin's lisp directory must contain a Lisp file
6276 named <filename>jde-PLUGIN.el </filename>where PLUGIN is
6277 the same as the plugin's toplevel directory name. This
6278 file is called a bootstrap file because it is the only
6279 file directly loaded by the JDEE. It is responsible for
6280 registering the plugin with the JDEE and loading any other
6281 Lisp files required by the plugin.</para>
6289 <title><anchor id="RegisteringPlugin"/>Registering a Plugin</title>
6291 <para>A plugin's bootstrap file must register the plugin with
6292 the JDEE when it is loaded. The bootstrap file should do
6293 this by invoking the JDEE's
6294 <function>jde-pi-register</function> function. This function
6295 takes a single argument: an instance of
6296 <varname>jde-plugin</varname> class that optionally
6297 specifies the plugin's menu and its contribution to the
6298 classpath of the instance of the BeanShell run by the
6304 <title>Running Java Code from a Plugin</title>
6306 <para>A plugin can use the JDEE's instance of the BeanShell to
6307 invoke Java methods and display their output in an Emacs
6308 buffer. The JDEE provides the following functions for this
6314 <para><function>jde-jeval</function></para>
6315 <para>Evaluate a Java statement in the JDEE's BeanShell
6316 instance and return the resulting BeanShell
6321 <para><function>jde-jeval-r</function></para>
6322 <para>Evaluate a Java statement in the JDEE's BeanShell
6323 instance, use the Emacs Lisp interpreter to evaluate the
6324 resulting BeanShell output, and return the result. This
6325 function assumes that the Java statement emits Emacs
6326 Lisp code, i.e., that the Java code was developed
6327 specifically to cause Emacs to do something.
6332 <para><function>jde-jeval-cm</function></para>
6333 <para>Evaluate a Java statement in the JDEE's BeanShell
6334 instance and display the resulting BeanShell output in
6335 an Emacs compilation buffer. This function is intended
6336 to run Java applications, such as style checkers, that
6337 output error messages keyed to specific lines in a
6344 <para>See the doc strings for these functions for more information.</para>
6352 <title><anchor id="BootstrapExample"/>Bootstrap File Example</title>
6355 The following is an example of the bootstrap file
6356 for a plugin named pi1.</para>
6361 (defun jde-pi1-cmd ()
6363 (message "plugin 1"))
6369 (expand-file-name "lib/lib1.jar" (jde-pi-get-plugin-dir "pi1"))
6370 (expand-file-name "lib/lib2.jar" (jde-pi-get-plugin-dir "pi1")))
6371 :menu-spec (list (list "Pi1" ["cmd" jde-pi1-cmd :active t]))))
6394 sgml-insert-missing-element-comment: nil