python - Get a lot of errors (Exceptions) while trying to call Java-classes (Neo4j) with JPype -


i'm trying work java , python bridge jpype, neo4j (which graph database). when try run simple java-program jpype, there no problems.

import jpype jp  jp.startjvm(jp.getdefaultjvmpath(), "-ea") javaclass = jp.jclass('jpype_test.a2') javainstance = javaclass() javainstance.callme(2, 3) jp.shutdownjvm() 

and class in java just:

package jpype_test;  import helloworld.embeddedneo4j;  import java.io.ioexception;  public class a2 {     public a2() {         super();      }      public string callme(final int a, final int b) throws ioexception {         final int res = math.abs(a - b);         try {             embeddedneo4j.main(null);         } {             system.out.println("i can't this!");         }          return ("hello, world!" + res);     } } 

but when try run "same" helloworld-program written including neo4j, there lot of errors , don't understand i'm doing wrong.

package helloworld;  import java.io.file; import java.io.ioexception;  import org.neo4j.graphdb.direction; import org.neo4j.graphdb.graphdatabaseservice; import org.neo4j.graphdb.node; import org.neo4j.graphdb.relationship; import org.neo4j.graphdb.relationshiptype; import org.neo4j.graphdb.transaction; import org.neo4j.graphdb.factory.graphdatabasefactory; import org.neo4j.io.fs.fileutils;  public class helloworld {  private static final string db_path = "target/neo4j-hello-db";  public string greeting;  graphdatabaseservice graphdb; node firstnode; node secondnode; relationship rs;  private static enum reltypes implements relationshiptype {     knows }  public static void main(final string[] args) throws ioexception {     final helloworld hello = new helloworld();     hello.createdb();     hello.removedata();     hello.shutdown();  }  void createdb() throws ioexception {     fileutils.deleterecursively(new file(db_path));     graphdb = new graphdatabasefactory().newembeddeddatabase(db_path);     registershutdownhook(graphdb);      try (transaction tx = graphdb.begintx()) {         firstnode = graphdb.createnode();         firstnode.setproperty("message", "hello, ");         secondnode = graphdb.createnode();         secondnode.setproperty("message", "world!");          rs = firstnode.createrelationshipto(secondnode, reltypes.knows);         rs.setproperty("message", "brave neo");          system.out.println(firstnode.getproperty("message"));         system.out.println(rs.getproperty("message"));         system.out.println(secondnode.getproperty("message"));          greeting = ((string) firstnode.getproperty("message")) + ((string) rs.getproperty("message"))                 + ((string) secondnode.getproperty("message"));          tx.success();      } }  void removedata() {     try (transaction tx = graphdb.begintx()) {         firstnode.getsinglerelationship(reltypes.knows, direction.outgoing).delete();         firstnode.delete();         secondnode.delete();          tx.success();     } }  void shutdown() {     system.out.println();     system.out.println("shutting down database......");     graphdb.shutdown(); }  private static void registershutdownhook(final graphdatabaseservice graphdb) {     runtime.getruntime().addshutdownhook(new thread() {         @override         public void run() {             graphdb.shutdown();         }     }); } 

}

>> traceback (most recent call last):     file "c:\projects\argon\workspace\testneo4jproject\src\helloworld\file.py",   line 6, in <module>     javaclass = jp.jclass('helloworld.hello')   file "c:\python27\lib\site-packages\jpype\_jclass.py", line 54, in jclass     raise _runtimeexception.pyexc("class %s not found" % name) jpype._jexception.exceptionpyraisable: java.lang.exception: class helloworld.hello not found 

i suppose there problem classpath or this, looks quite weird me.. thank's lot if can solution!

the exception states: class helloworld.hello not found. class named helloworld.helloworld. so, either make sure invoking right class name, or change class name helloworld.hello.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -