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!