User Tools

Site Tools


documents:100825imagej_jython_eclipse

Elcipse-Pydev-Jython-ImageJ Interactive Environment

Setting Up Environment

1. Install Jython

From jython site, download Jython 2.5.1.

http://www.jython.org/downloads.html

Double click the file and install. You do not need to change default values for the installation (Standard in “Installation Type”), but keep in your mind where Jython was installed.

2. Eclipse for Java

Download Eclipse IDE for Java Developers from

http://www.eclipse.org/downloads/

All you need to do is unpack the compressed file, and place the folder “eclipse” somewhere. Double clicking eclipse.exe (win) or eclipse (Mac) will start the eclipse. When you start up eclipse, you will be asked for where the “workspace” is. Create a new folder somewhere to store files generated during your coding, and select that folder as “workspace”. You could add more workspaces later, so think of this as a test.

In the first startup screen (saying “welcome to the Eclipse” brah brah), all you need to do is click icon at the right side “Workbench”.

3. Install Pydev plugin in Eclipse

Pydev is a plugin for using Python and Jython. In eclipse, go [Help - Install New Software]. In “Install” window, copy and paste the following http address in “work with”:

http://pydev.org/updates

You will then see list of modules in below. Check “Pydev”, and at the bottom, click “Next”. Eclipse will start to download and Install the file. If you want to know details about the Pydev plugin, go to http://pydev.org/

4. Setting up Jython Interpreter

Select [Window - Preferences]. A window pops up. From the left panel, click “pydev” see the sub list.

Choose “Interpreter - Jython”. You will then see in the right panel “Jython Interpreter” setting. Click “New…” button in the top-right. “Select Interpreter” window appears. Click “Browse” button. In another window, go to the directory where you installed Jython in the Step 1 and then choose jython.jar (in Windows, this will be C:\jython2.5.1\jython.jar if all settings down to here were done by default).

Eclipse starts to load files then. There will be another window asking you for “selection needed”, bu leave it as selected and click OK. You will then see “System PYTHONPATH” field is added wit list of files. Click OK. You are done.

5. Testing Jython Interpreter

[File - New -Other] and select Pydev - Pydev Project.Click [Next>]. name the Project Name “testjython”. From Project type, choose “Jython”. Click [Finish]. Eclipse asks you if you want to associate the Pydev perspective. Click [Yes] (maybe check “remember my decision” ).

In the left panel “Pydev package Explorer”, you now see 'testjython' project. Right click the project folder and from the menu, select “properties” (at the bottom of the menu). From the listing in the left, select “Pydev -PYTHOMPATH”. Then in the right panel, Click the “External Libraries”. Click “Add zip/jar/egg” button in the left, and find your ImageJ folder and choose “ij.jar” and “Open”. You now should see the selected ij.jar in the field. click OK.

Now, you are ready to start using Jython.

do [Window - Show View - Console]

and then a new tab named “console” will appear at the bottom panel. Along the bottom panel manu (we call it console menu), you will find several icons at the left, and the third from left is an icon of small window (1cm or so in size) with yellow plus-sign at the right top corner. Click black triangle at the right of icon, and drop-down menu appears. Select “Pydev console”. A dialogue window pops up, so select Jython console and click OK.

You will see texts that looks like this appears in the console:

>>> import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
java1.6.0_21 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54) 
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] 

If you see this, then you are now in the interactive mode of Jython. Type following text besides greenish “»>”

import ij.IJ

if nothing happens and returns, you have successfully imported ImageJ. You can now access all the ImageJ Java classes from command line interactively.

To exit from the interactive mode, click red button in the console menu. The button turns gray and interactive mode stops.

documents/100825imagej_jython_eclipse.txt · Last modified: 2016/05/24 12:46 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki