-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcalc.py
More file actions
30 lines (28 loc) · 782 Bytes
/
calc.py
File metadata and controls
30 lines (28 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from jpype import startJVM, shutdownJVM, java, addClassPath, JClass, JInt
startJVM(convertStrings=False)
import jpype.imports
#addClassPath("org/pkg")
#from org.pkg import MyMath
#import MyMath
#import org.pkg as p
#print(p)
#print(p.__class__)
try:
pass
#print(dir(p))
#p.MyMath.divide(6, 2)
#import Calculator
calc = JClass('Calculator')
print(calc)
print(dir(calc))
res = calc.add(java.lang.Integer(2), java.lang.Integer(2))
print(res)
#from org.pkg import Calculator
math = JClass('org.pkg.MyMath')
res = math.divide(java.lang.Integer(6), java.lang.Integer(2))
#res = math.divide(JInt(6), java.lang.Integer(2))
print(res)
#calc = Calculator()
#print(calc)
except Exception as err:
print(f"Exception: {err}")