The following describes common problems using the JDE and their solutions.
Problem I can't get the JDE to use Internet Explorer to display the JDK doc or the JDE User's Guide.
Solution The JDE uses Emacs browse-url interface to web browsers. browse-url supports Netscape by default. To use Internet Explorer:
- Add the following code to your .emacs file(if (eq system-type 'windows-nt) (defadvice browse-url-generic (around show-window act) "*Sets `start-process-show-window' on." (let ((w32-start-process-show-window t)) ad-do-it)))
This code causes Emacs to show the window of the browser launched by the function browse-url-generic.
- Customize the variable browse-url-generic-program to specify iexplore as the "generic" browser on your system.
(To display the custom buffer for browse-url, executeM-x customize-group browse-url)
After you have done this, the custom buffer should look likeBrowse Url Generic Program [Hide] [Value Menu] String d/applications/ie4/iexplore [State] this option has been set and saved. The name of the browser program used by `browse-url-generic'.
- Customize the variable browse-url-browser-function to specifybrowse-url-generic
as the function that invokes the browser when the command browse-url is executed.
After you have done this, the custom buffer should look like this:Browse Url Browser Function [Hide] [Value Menu] browse-url-generic Ask the WWW browser defined by `browse-url-generic-program' to load URL. [More] [State] this option has been set and saved. Function to display the current buffer in a WWW browser. [More]
- Restart Emacs.
Problem: I've just updated to Emacs 20.3.1 and the latest JDE. I used to set my CLASSPATH in my .emacs as follows:
(setq jde-global-classpath '("c:/jdk1.1.7/lib/classes.zip" "."))
However, this no longer takes effect, and I seem forced to use customize.
Is this a deliberate change in policy?
Solution: Yes, you must use custom to customize JDE variables (or at least duplicate its behavior). The reason is that custom on most versions of Emacs does not allow customization of buffer-local variables. This conflicts with the need for the JDE to support project-specific customization of JDE variables. The JDE solves this problem by taking advantage of the fact that custom stores the standard and customized values of a variable as properties of the variable. Whenever you open or switch Java source buffers, the JDE resets the values of each JDE variable according to the following rules:
- If a prj.el file exists in the directory tree containing the new buffer's source file, the JDE sets the value of the JDE variable to the value stored for that variable in the prj.el file.
This rule ensures that variables are set to project-specific values in buffers that are associated with projects.
- If there is no prj.el file and the variable has a customized-value property, the JDE sets the value of the JDE variable to the value stored in the customized-value property.
Custom creates and sets the customized-value property to the value you specify when you customize a variable and select the Save for future sessions option from custom's State menu, which saves the value by default in your .emacs file. This rule ensures that variables that you have customized are reset to the customized value saved in your .emacs file, when you switch from a source buffer that is associated with a project to a source buffer that is not associated with a project.
- If there is no prj.el file and no customized-value property, the JDE sets the value of the JDE variable to the value stored in the variable's standard-value property.
Custom sets the standard-value property of a JDE variable to the value defined by the JDE. This rule ensures that a non-customized variable is set to the standard value when you switch from a buffer that is associated with a project to a buffer that is not associated with a project.
As you can see from the foregoing, the JDE resets the value of each JDE variable whenever you open or switch buffers to either a value stored in a prj.el file or to a value stored as a property of the variable. Thus, any value set by a setq statement in your .emacs file will be overwritten. So if you want to customize a variable in your .emacs file, you have two options:
Open a customization buffer for the variable, edit the standard value, and save the result by selecting the Save for future sessions option from custom's State menu.
Set the value of the variable's customized-value property to the customized value, using a put form in your .emacs file, for example,
(put 'jde-compiler 'customized-value "jikes")
Problem: I would like to change the default value of the cc-mode customization variable c-basic-offset for use with JDE - but alas, I've had no luck in doing so. No matter what I've attempted, editing a Java source file always ends up with the original value of 4 rather than the value of 2 that I've specified.
cc-mode's default "style" for editing Java code (which JDE inherits) resets c-basic-offset to 4 whenever you open a Java buffer.
Solution: The following, which you should put in your .emacs file, sets it back to 2.
(defun my-jde-mode-hook ()
(setq c-basic-offset 2))
(add-hook 'jde-mode-hook 'my-jde-mode-hook)
Problem: I start the debugger but the Jdb menu does not appear on the Emacs menu bar as pictured in the user's guide.
Solution: Set an initial breakpoint in the jdb command buffer and run to that breakpoint. Then, select the Java source buffer in which the debug cursor appears. You should see the Jdb menu on the menubar. Note: that the Jdb menu appears only after an initial breakpoint has been reached and when a Java source buffer is selected. See the JDE User's Guide for more information.
Problem When I compile a file, the compilation command is including invalid flags.I am using the latest version of the JDE with JDK 1.1.x.
Solution The JDE's compile command (selected via JDE->Compile) invokes the compiler with command-line arguments that select the compiler options you have chosen via the JDE->Options->Compile command. The command line switches accepted by the JDK 1.2 version of javac changed somewhat from those accepted earlier versions. By default, the JDE compile command uses the command-line switches defined by the JDK 1.2 version. If you are using earlier versions of javac and you want to use a command-line switch that is no longer supported by JDK 1.2 or has changed, you have two options. In the case of the -depend switch, which changed to -Xdepend in Java 1.2, you can cause the JDE to revert to the earlier form by setting the jde-compile-option-depend-switch. In fact, you need to do this, if you want to use the JDE's Java build command (JDE->Build). For other switches that have changed, you can specify the earlier form via the jde-compile-option-command-line-arg option.