9.4. Java Support


As we mentioned earlier, recent versions of Emacs come with support for Java built-in (Java mode is based on cc-mode). We'll explore Java mode briefly and then take a more in-depth look at the Java Development Environment for Emacs (JDEE).

9.4.1 Java Mode

Java mode shares all of the formatting and font features mentioned above, but understands the Java language specifically. You get thrown into Java mode when opening any .java file.

When working in Java mode, you have exactly the same features available as you do in C mode. Syntax highlighting handles Java keywords and syntax when font-lock mode is turned on. You can navigate Java commands using M-a and M-e. When commenting out a region, it uses the C++ style // comments.

You'll notice a small augmentation in the indent alignment commands if you choose to spread your throws or extends clauses over multiple lines. For example, consider the following method declaration:

public Object getNetResource(String host, int port, String resName)  throws IllegalArgumentException,  IOException,  SQLException,  FileNotFoundException {

If you mark the region and run M-C-\ to indent the region, it uses a special alignment for the exception list:

public Object getNetResource(String host, int port, String resName)          throws IllegalArgumentException,                 IOException,                 SQLException,                 FileNotFoundException {

It all works like it is supposed to just with Java as the language at the core of the action. However, for more than casual Java editing, you should read the next section on the JDEE.



Learning GNU Emacs
Learning GNU Emacs, Third Edition
ISBN: 0596006489
EAN: 2147483647
Year: 2003
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net