Eclipse Plugin Setup Instructions

Sam Neth and Eric Bloch
Last updated September 14, 2011

As of MarkLogic 6, Java developers now have the additional option of using the MarkLogic Java API

XQDT is a set of open source plugins for the Eclipse IDE, providing support for syntax highlighting and content-assisted editing of XQuery modules, and a framework for executing and debugging modules in a supported XQuery interpreter.  The MarkLogic-specific extensions currently available add support for MarkLogic's syntax extensions, and auto-completion and integrated reference material for the entire MarkLogic API.  Modules can be executed on the server, with results displayed in the IDE.  Debugging is not yet supported.

System Requirements

Java

Eclipse requires but does not include a Java Virtual Machine.  Most developers will already have Java installed, though non-Java developers on Windows machines may need to install Java before installing Eclipse.  Java can generally be obtained here:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

While many versions of Java are capable of running Eclipse without any problems, if you have difficulty with these instructions, the version of Java installed on your machine may be the source of the problem.  Check eclipse.org for information about versions of Java used in formal testing of Eclipse:

http://www.eclipse.org/downloads/moreinfo/jre.php

Eclipse IDE

The screenshots herein are from Mac OS X, but binaries for the Eclipse IDE are available for virtually any desktop environment, and XQDT should work on any of them.  The version of XQDT we provide can be used with Eclipse 3.6 (Helios) or Eclipse 3.7 (Indigo).  Unless you need to run a different version, 3.6 (Helios) is recommended.

MarkLogic Server

The MarkLogic capabilities of XQDT can interoperate with any version of MarkLogic Server.  The server need not be running on the workstation where the IDE is installed.  An XDBC server must be configured through which XQDT can send semantic validation and module execution requests.

Set Up MarkLogic Server

It is beyond the scope of this document to describe the procedure for downloading and installing MarkLogic Server, or to detail the configuration of the server.  Assuming you have the server installed and running, enabling XQDT simply requires creating an XDBC server.  

In the Admin Interface, navigate to Groups > Default > App Servers.  

Select the Create XDBC tab, fill in the required fields, and click Ok

Remember the port number for the new server for use in setting up XQDT.

Install Eclipse IDE

Before installing XQDT, you need a copy of Eclipse IDE.  You will generally be able to install XQDT in an existing copy, but if you prefer to keep your XQDT environment separate, or run into trouble getting XQDT to work properly, you may wish to install a fresh copy.  You can download an installer from one of the following links:

Eclipse 3.6.2 (Helios) [ Recommended ]

http://www.eclipse.org/downloads/packages/release/helios/sr2

Eclipse 3.7 (Indigo)

http://www.eclipse.org/downloads

Launch Eclipse IDE

When you launch Eclipse you will be prompted for a workspace location.  The workspace will be the parent directory of your eclipse projects.  You may wish to check the box indicating that Eclipse should use your workspace at startup automatically.  The workspace can always be changed from within Eclipse by selecting File > Switch Workspace from the menu.

Workspace Launcher

Install XQDT as a dropin

The current version of XQDT from the Eclipse update site will not work with MarkLogic.  While this issue remains, kindly download a copy of XQDT from http://developer.marklogic.com/download/code/eclipse/xqdt-dropin.zip and unpack it into the dropins folder underneath Eclipse.  You should see the following hierarchy underneath the main Eclipse folder with the zip unpacked into the dropins folder.
 
Eclipse Folder
 
Restart Eclipse when you are done.
 
Note:  MarkLogic has verified this method of installing XQDT works in a virgin install of Eclipse 3.6.2 (Helios) as well as Eclipse 3.7 (Indigo), but recommends you use Eclipse 3.6.2.  It is possible that these jars, when installed in 3.7, may cause conflicts in the future.  If you have issues installing XQDT this way in non-virgin Eclipse installations, we're happy to help.  So, let us know.

Pre-configured Eclipse IDE + XQDT for Windows

If you are using a Windows environment, you may find it easier to install a pre-configured version of Eclipse.  This is a 32-bit version of eclipse, which requires a 32-bit version of Java.  You can also find a copy of Windows 32-bit Java at java32_usefor64too.zip. This version of Java will run on 32-bit or 64-bit Windows machines.

[ This package contains an older version of the software, so self-installation is recommended. ]

Create your first XQuery Project

From the menu bar, select File > New > Project...

File > New > Project

Choose XQuery / XQuery Project and click [Next...]

New Project

Enter a name for your project, and click [Configure interpreters...] to configure XQDT to communicate with MarkLogic Server.

New XQuery ProjectIn the interpreters dialog, click [Add...]

Configure Interpreters

Change Interpreter type to "MarkLogic Server" and configure the connection with the URL for accessing your XDBC server, (Example: xcc://localhost:8888), and the username and password for authentication of requests to the server.

Add Interpreter

Click [Ok] to save the new interpreter, and again to exit the interpreters dialog.

Click [Finish]

When Eclipse asks if you would like to switch to the XQuery perspective, click [Yes]

XQuery Perspective

Create an XQuery Module

From the menu bar, select File > New > XQuery Module

File > New > XQuery Module

(This option appears if you're in the XQuery perspective.  You can also select it from the New > Other... dialog)

Choose a module type and give it a name, click [Finish].

New XQuery Module

Test an XQuery Module

From a module editor window, ensure the module is saved, and run it by selecting Run > Run from the menu bar.  There are a number of other ways to run a module, using context menus or toolbar buttons.  Your results will be displayed in the Eclipse Console panel.  Note that only main modules can be executed.  

Test XQuery

Helpful Hints

XQuery Version Prolog

XQDT uses the version prolog to enable MarkLogic-specific features.  It is always good practice to begin your modules with a version prolog, in order to guarantee correct behavior independent of the default settings of a particular MarkLogic Server instance.  In general, your modules should start with the following:

xquery version "1.0-ml";

XQuery Module Directory

XQDT requires that XQuery modules be stored inside your project directory; XQuery modules outside the project directory can be opened and the XQuery editor will be mostly functional, but some features will not work in this scenario.

Resources

XQDT project page at eclipse.org:

http://wiki.eclipse.org/XQDT

Please file bug or enhancement requests in eclipse bugzilla; free account setup is quick and painless.

XQDT commercial adopters website / blog:

http://www.xqdt.org/

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.