I have created a java interface and implement it using python code, created a jython factory to get the code file
here is my code:

the java interface :
-------------------------
package drugInterAction;

public interface DrugInterActionInterface {
    public String checkInterAction(String drugs);
}


the jython factory:
-------------------------
package drugInterAction;

import org.python.util.PythonInterpreter;

public class JythonFactory {
   
    public static DrugInterActionInterface  getDrugInteractionInterfaceInstance(String file) {//file is the python file path
        PythonInterpreter interpreter = new PythonInterpreter();
        interpreter.execfile(file);
        String instanceName = "newInst";
        interpreter.exec(instanceName + " = DrugInteraction()");
        DrugInterActionInterface iTest = (DrugInterActionInterface)
        interpreter.get(instanceName).__tojava__(DrugInterActionInterface.class);
        return iTest;
      }
}

the python file code:
------------------------------
from drugInterAction import DrugInterActionInterface
import sys, string, xmlrpclib

class DrugInteraction(DrugInterActionInterface):
       
    def __init__(self):
        self.resultData = ''
        self.url = "http://hherb.com"
        self.port = 8001
        self.server_url = "%s:%d" % (self.url, self.port)
        self.effects = {'i':'inhibits (non-clinical)', 'I':'inhibits', 'a':'augments (non-clinical)', 'A':'augments'}
        print self.server_url
        self.server=xmlrpclib.ServerProxy(self.server_url)
        print "Connected"
        return
   
    def checkInterAction(self,drugs):
        print "checking interaction between: " + drugs
        self.druglist = string.split(drugs, ',')
        print self.druglist
        self.results = self.server.interaction(self.druglist)
        for self.result in self.results:
            self.drug, = self.server.atc2text(self.result['drug'])
            self.affected_drug, = self.server.atc2text(self.result['affected_drug'])
            self.effect = self.effects[self.result['effect']]
            resultData+= ','+"%s (%s) %s %s (%s); evidence=%s; reference=%d" % (self.drug['text'], self.drug['code'], self.effect, self.affected_drug['text'], self.affected_drug['code'], self.result['evidence'], self.result['reference'])
            print "%s (%s) %s %s (%s); evidence=%s; reference=%d" % (self.drug['text'], self.drug['code'], self.effect, self.affected_drug['text'], self.affected_drug['code'], self.result['evidence'], self.result['reference'])
        return string.split(drugs,',')

but when i run this code I get the following error :
----------------------------------------------------------------------
Exception in thread "main" Traceback (innermost last):
  File "J:/drugInter.py", line 2, in ?
ImportError: no module named string
Java Result: 1


can any one help me with this please ????



Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail Beta.