Re: [Jpype-users] Problem with JPype (newbie)
Status: Beta
Brought to you by:
devilwolf
From: Tobias I. <th...@gm...> - 2007-06-18 13:00:38
|
I don't know if you have received any response from anyone else. I have had this email in my todo-queue for a few days now, and had some time to reply to it today. It sounds to me as if you are having classpath issues (the most disturbing problem in the java-world in my opinion). How do you ensure that the package containing your class-files are reachable by the JVM? I have found that the best way is to put the jar in the java extension directory. I believe it is located at $JAVA_HOME\lib\ext on windows. Try to put weka.jar there, that worked for me in a similar case. I really think that the JPype startJVM method would be better if it had a name-only parameter called classpath for specifying the classpath, since this is something one would quite often do, and the current way of specifying the classpath is quite awkward. /Tobias On 6/13/07, lc...@cs... <lc...@cs...> wrote: > > Hi, > > I am a newbie in python and JPype. I need to use JPype to communicate > a python program with the java program. I tested a small java program > that didn't have any external jar file (it just uses java.lang > library) and I called it from a python program using JPype and It > works fine. I am using version JPype-0.5.2.1, wich is the latest that > I found for python 2.4 (running on windows). I am trying to run a > program that uses the datamining library, weka, that is written in > java (it is in a jar file: weka.jar which is in defined in the > classpath, and when I run the java program independently it works > fine). My problem is that I get the following error message when I > 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: > 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 = 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 = new CSVLoader(); > loader.setSource(new File(inputfile)); > Instances data = loader.getDataSet(); > > // save ARFF > ArffSaver saver = 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 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jpype-users mailing list > Jpy...@li... > https://lists.sourceforge.net/lists/listinfo/jpype-users > |