0

Help!

I'm trying to create a custom class using Jpype. I'm running 64 bit python and 64 bit jdk on a mac. This is the error I am getting:

`jpype._jexception.ExceptionPyRaisable: java.lang.Exception: Class A not found

`
I have looked at the other questions on StackOverflow for this question.

Below is the .py code. The commented lines show the things I have tried:

#jpype.startJVM("/System/Library/Frameworks/JavaVM.framework/JavaVM", "-ea", "-Djava.class.path=%s"%os.path.abspath("/Users/hujen/Desktop/currResearch/pythonScript/class/"))
jpype.startJVM("/System/Library/Frameworks/JavaVM.framework/JavaVM","-ea", "-Djava.class.path=C:/Users/hujen/Desktop/currResearch/pythonScript/class/")
#jpype.startJVM("/System/Library/Frameworks/JavaVM.framework/JavaVM")
#jpype.startJVM(jpype.getDefaultJVMPath())
jpype.java.lang.System.out.println("Hello World!")
jpype.java.lang.System.out.println("This program will implement the original parse python code in a jvm")
jpype.java.lang.System.out.println(jpype.JString("H"))
util = jpype.JPackage("java.util")
al = util.ArrayList()
al.add(1)
al.add(2)
print al.size()


A = jpype.JClass("A")
a = A()

print a.sayHi()

print A.add(3,4)

A.main(["first"])
jpype.shutdownJVM()

This is the class file. I saved it as A.java. I ran it using

javac -g A.java

to get the .class extension.

 public class A
    {
        public A()
        {
            super();
        }
        public String sayHi()
        {
            return("Hello");
        }

        public static void main(String[] argv)
        {
            System.out.println ("Hello "+argv[0]);
        }

        public static int add(int a, int b)
        {
            return(a+b);
        }
    }

Thanks!

  • What OS are you using? It looks like mac, but you have `C:/Users/...` Where is your A.class file saved, and what package are you declaring it to use (you're not using the default package, are you)? – Falmarri Jul 31 '14 at 23:32
  • I am using MacOSX 10.9.3. The A.class is saved at: /Users/hujen/Desktop/currResearch/pythonScript. I'm not sure about package. I'm new to Java, too. I'm assuming I'm using the default package. I'm trying to go through this tutorial: [link](http://iacobelli.cl/blog/?p=119) – user3547377 Jul 31 '14 at 23:49

0 Answers0