Setting up an IDE : Eclipse |
Editor(s): KeiichiroOno PietMolenaar |
Date: September 12th 2011 |
Status: Updated for Cytoscape 3 M3 release. |
Contents
Introduction
This is an introduction to Cytoscape 3 Plugin development for Eclipse users.
Prerequisites
You need to know basics of Eclipse and Maven.
Install JDK
To develop Cytoscape 3, you need Java 6 or 7. If you find problems on Java 7, please let us know.
Setting up Eclipse
This procedure had been tested with latest version of Eclipse, Indigo. You can use any version of Eclipse distribution, but we recommend to use Eclipse for RCP and RAP Developers or Eclipse IDE for Java Developers.
Use JDK, not JRE Make sure eclipse is running in the JDK virtual machine; on Windows this is not default. To use JDK's VM, create a shortcut and edit the shortcut's property: eclipse.exe -vm "c:\your_path_to_JDK\bin\javaw.exe"
Installing Plugin From Eclipse Marketplace
Eclipse Indigo supports plugin store called Eclipse Marketplace. All of the following plugins are available from the Marketplace. To install plugins, open the Marketplace dialog (Help → Eclipse Marketplace), type plugin name in the search box, and click install button.
Usually, you will be asked to restart Eclipse after installing plugins.
Plugins to install
You need to install some plugins to develop Cytoscape 3 plugins. All of the following are required to develop Cytoscape 3 (or any Java applications using Maven and Spring).
Subclipse
To access our Subversion repository from Eclipse, you need to install Subversion client software for Eclipse. In this tutorial, we use Subclipse plugin.
Extensions for Subclipse By default, some of the essential functions are not installed with Subclipse. In some environments, you need to install some extra software (Help → Install New Software). We recommend to install Java Native Subversion Client:
To use this client from Eclipse, you need to switch client to SVNKit.
m2eclipse
M2Eclipse is a plugin to integrate Maven to Eclipse. ow it is a part of Eclipse foundation
Many useful documents are available from the project and we recommend to read them.
Installing Extensions for m2eclipse Latest version of m2eclipse plugin uses its own extension system. You can install useful extensions for
The following extensions should be installed:
- m2e-sublcipse
- maven.runtime.3.0.3
- m2e connector for maven-scm-plugin
- m2e connector for org.codehaus.mojo:jaxb2-maven-plugin and org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
Spring IDE
Spring IDE helps you to debug/refactor Spring setting files on Eclipse. This is not required to build your plugin, but we strongly recommend to use this if you create Cytoscape 3 Native plugins.
Checkout Cytoscape 3 Plugin Developer's Template Project
Select File→New→Other→Maven→Checkout Maven Projects from SCM
Select Source Code Management (SCM) system type to svn
Make sure the URL is set to http://chianti.ucsd.edu/svn/core3/plugin-developer/trunk/ (for core developers, svn+ssh://grenache.ucsd.edu/cellar/common/svn/core3/plugin-developer/trunk/).
- Click 'finish' and you'll end up with something like this:
Build Plugin Developer's Template Project
Right-click cytoscape project top folder
Select Run As → Maven Build
Type clean install in the Goals text box
Click Run button
Now you can see the following directory structure under target directory:
Run Cytoscape 3
- Open command-line terminal.
Go into target directory you've just created with m2eclipse plugin
Execute cytoscape.sh (for unix/mac) or cytoscape.bat (windows)
If you can run Cytoscape, now you are ready to code your plugin.
Create Plugin
There are two types of plugins for Cytoscape 3 and you can use Eclipse for both of them.
Simple Plugin
Select New → Java Project
Enter project name. This can be anything. In this example, we use Cy3SimplePlugin as a sample plugin name.
Add cytoscape-plugin-api jar file as a library
Right-click src folder and create a class file HelloWorldPlugin. Use org.cytoscape.sample as its package name
Create Manifest file. It's just a text file named MANIFEST.MF. The only entry you need to write in this file is the following:
Manifest-Version: 1.0 Cytoscape-Plugin: org.cytoscape.sample.HelloWorldPlugin
This is your Plugin's main class name.
- Your project directory looks like this:
- Write Plugin main class:
1 package org.cytoscape.sample; 2 3 import org.cytoscape.plugin.CyPlugin; 4 import org.cytoscape.plugin.CyPluginAdapter; 5 6 public class HelloWorldPlugin extends CyPlugin { 7 8 public HelloWorldPlugin(CyPluginAdapter adapter) { 9 super(adapter); 10 11 System.out.println("Hello Cytoscape 3!"); 12 } 13 } 14
Select File>Export
Select JAR FIle and click Next
Uncheck MANIFEST.MF file. Otherwise, two manifest files will be created in the JAR!
Type plugin jar file name and click Next
Leave all settings as-is and click Next
Select Use existing manifest from workspace and specify the one you've just created
Click Finish. Make sure the plugin jar file exists in the directory you specified above.
Test your plugin
- Run Cytoscape from command-line
Select Plugins>Plugin Manager
Select Import Local Plugin tab
Click Select button and select the plugin jar file you've created
You can see Hello Cytoscape 3! in the console
For more realistic example, please try this tutorial:
Tutorial:Creating a Simple Cytoscape 3 Plugin
Cytoscape 3 Bundle Plugin
If you want to create Cytoscape 3 Native bundle plugin, please try the following tutorial:
Tutorial:Creating an OSGi Bundle Cytoscape 3 Plugin
Questions?
If you find problems or have questions, please let us know.