Using NetBeans to build Spring/Python applications

Contributed By: Kristian Rink


[[{TableOfContentsTitle=TableOfContents} | {TableOfContents title='Table of Contents'}]]



To follow this tutorial, your system should meet the following requirements:

  • NetBeans IDE 6.7 (or development build)
  • Python is installed and running on your system (Jython won't work it seems due to some features obviously not implemented yet but required by Pyro which Spring Python depends upon
  • You should have a basic understanding of how to generally work with NetBeans, create files / projects, run projects and so forth.


Install NetBeans Python plugins

In order to do Python development using NetBeans IDE, you have to install the Python plugins provided by the NetBeans update centers. Though (as pointed out before) Jython doesn't work with Spring Python at the moment, having it installed doesn't hurt as it easily allows for integrating Python with your Java applications if you feel like doing so, later:


After installing the modules, you should restart the IDE to have the Python tooling activated and ready to use.

Install Spring Python and dependencies

Spring Python itself should be downloaded here. After downloading, extract the .zip files to some meaningful place on your local drive. In order to use Spring Python, you will also need to have...

  • ... the "Python Remote Objects" (pyro) package installed, which either can be downloaded here or, on a recent GNU/Linux distribution, installed via the distribution package manager (
    sudo apt-get install pyro
    on Ubuntu or other dpkg based systems). Likewise, in NetBeans' Python Platform Manager ("Tools" -> "Python Platforms"), please make sure the "Python Path" settings for your local Python environment contains {/usr/share/pyshared} as otherwise Spring Python applications will not work complaining about missing Pyro dependencies.
  • ... the "python-amara" libraries for processing XML, which can be downloaded here or installed using your distribution package management, as well (
    apt-get install python-amara


Working with Spring Python

Create a new project

In the IDE, choose "File" -> "New Project" to create a new project, and choose "Python" -> "Python Project" as your starting point:


Asides entering a meaningful name and disk folder, you should ensure that "Python Platform" for this project is set to use Python not Jython (the latter usually being preselected by default):


The IDE tooling by then should create a new, empty Python project and a main file for you and, once finished, display a project structure and an opened Python editor more or less like this:


Adding the Spring Python library

Now, to add the Spring Python library to the project, right-click it in "Projects" window, choose "Properties" -> "Python" and use "Add" to add the Spring Python folder you extracted before (by unpacking the Spring python distribution .zip file) to "Python Path":


This way, your IDE should have the Spring Python libraries available to this project.

Test-driving the framework

As Spring Python tries to resemble most of the features provided to Java programmers by "classic" Spring, the idea of an "application context" is at the core of Spring Python as well. And, similar to Java Spring, in Spring Python this mainly configured using an XML configuration file. For that, in your newly created project, please choose the "<Top Level>" package to create a new XML file "context.xml" with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<objects xmlns="http://www.springframework.org/springpython/schema/objects"


This is where, later on, you are about to define your service objects usable by other components in your context. Next, open the main .py file automatically created in the project and add the following content:

from springpython.context import ApplicationContext
from springpython.config import XMLConfig

container = ApplicationContext(XMLConfig("context.xml"))
print container

Doing so you might notice that, same as using a NetBeans Java editor, the Python editor provides features like syntax highlighting or CTRL-SPACE code completion also for the Spring Python classes which is rather helpful and definitely what you want if you're used to the Spring tooling for Java:



  1. Spring Framework Starting Page
  2. Spring Python Starting Page
  3. Spring Python Reference Documentation
  4. PYRO Python Remote Objects
  5. Dependency Injection / IoC
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo