[Jpype-users] Problem with JPype (newbie)
Status: Beta
Brought to you by:
devilwolf
From: <lc...@cs...> - 2007-06-13 04:42:11
|
Hi, I am a newbie in python and JPype. I need to use JPype to communicate =20 a python program with the java program. I tested a small java program =20 that didn't have any external jar file (it just uses java.lang =20 library) and I called it from a python program using JPype and It =20 works fine. I am using version JPype-0.5.2.1, wich is the latest that =20 I found for python 2.4 (running on windows). I am trying to run a =20 program that uses the datamining library, weka, that is written in =20 java (it is in a jar file: weka.jar which is in defined in the =20 classpath, and when I run the java program independently it works =20 fine). My problem is that I get the following error message when I =20 try to call the program from python using JPype: D:\Lorena\weka\examples>python Nav1.py Traceback (most recent call last): File "Nav1.py", line 7, in ? csvArffClass.convert("bank-data.csv","bank-data.arff") jpype._jexception.java.lang.LinkageErrorPyRaisable: =20 java.lang.NoClassDefFoundErr or: weka/core/converters/CSVLoader Here is the code: Nav1.py ------------ from jpype import * startJVM("c:/Program Files/Java/jdk1.6.0_01/jre/bin/server/jvm.dll", "-ea") csvArffClass =3D JClass("CSV2Arff") csvArffClass.convert("bank-data.csv","bank-data.arff") shutdownJVM() CSV2Arff.java -------------------- import weka.core.Instances; import weka.core.converters.ArffSaver; import weka.core.converters.CSVLoader; import java.io.File; public class CSV2Arff { public static void convert(String inputfile, String outputfile) { try { // load CSV CSVLoader loader =3D new CSVLoader(); loader.setSource(new File(inputfile)); Instances data =3D loader.getDataSet(); // save ARFF ArffSaver saver =3D new ArffSaver(); saver.setInstances(data); saver.setFile(new File(outputfile)); saver.setDestination(new File(outputfile)); saver.writeBatch(); } catch (Exception e) {} } } Please let me know what am I doing wrong?. Thanks, Lorena Carlo |