Next: , Previous: ede-cpp-root, Up: Simple projects

7.5.2 ede-java-root

Much like the project type ede-cpp-root, the java variant is can be setup in your .emacs file and just marks a directory as the root of a java source tree.

The ede-java-root project class knows a few things about Java projects. In particular, you can use it to control your classpath at both the system level, and for your project. If it is insufficient, you can subclass ede-java-root-project and add your own tweaks in just a few lines. See ede-cpp-root for an example using the C++ variant.

In the most basic case, add this to your .emacs file, modifying appropriate bits as needed.

     (ede-java-root-project "SOMENAME" :file "/dir/to/some/file" :srcroot '("src"))

Replace SOMENAME with whatever name you want, and the filename to an actual file at the root of your project. It might be a Makefile, a README file. Whatever. It doesn't matter. It's just a key to hang the rest of EDE off of.

Replace the value of :srcroot with a list of directories under the project root which contains Java sources. For example, if you have:


Then src represents the directory under which all your Java code is. It is important that src is one step above the directory that is the base of your package name, such as com/ericsoft in the example above so that new files can be discovered via fully qualified name. You can have multiple such directories in one project, and each will be accessible.

You can specify your classpath like this:

     (ede-java-root-project "NAME" :file "FILENAME"
         :srcroot '("src")
         :classpath '("/absolute/path.jar")
         :localclasspath '( "/relative/path.jar" ))

In this example, :classpath specifies absolute paths somewhere on your system, and the explicit jar or source root directories Semantic will search when performing completions.

The :localclasspath is like :classpath, but it will contain path names relative to the root of your project.

If you want to override the file-finding tool with your own function you can do this:

     (ede-java-root-project "NAME" :file "FILENAME" :locate-fcn 'MYFCN)

Where MYFCN is a symbol for a function. The locate function can be used in place of ede-expand-filename so you can quickly customize your custom target to use specialized local routines instead of the default EDE routines. The function symbol must take two arguments:

The name of the file to find.
The directory root for this java-root project.

If you would like to create your Java projects dynamically, instead of putting them all in your .emacs, you can do that too. See ede-cpp-root for details that can be applied to this project type.