-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunJavaClass.py
44 lines (27 loc) · 1.06 KB
/
RunJavaClass.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
# try:
import jpype
# KeyError:
# os.environ['JDK_HOME'] = "/Library/Java/JavaVirtualMachines/1.6.0.jdk"
# os.environ['JAVA_HOME'] = "/Library/Java/JavaVirtualMachines/1.6.0.jdk"
import time
class RunJavaClass:
def run(self):
# cpopt = "-Djava.class.path=%s" % './java_classes'
jpype.startJVM(jpype.get_default_jvm_path(), '-ea',
'-Djava.class.path=/Users/dawan/PycharmProjects/mamoc_server/java_classes')
# print(jpype.get_default_jvm_path())
# hey = jpype.java.lang.System.out.println("hello world")
# print(hey)
# testPkg = jpype.JPackage('uk').standrews.cs.mamoc
quick = jpype.JClass("QuickSort")
tic = time.time()
text_file = "./data/" + "medium" + ".txt"
with open(text_file, "r") as file:
content = file.read().split(" ")
quick.quickSort(content) # uk.ac.standrews.cs.mamoc.NQueens
duration = time.time() - tic
print(duration)
return duration
if __name__ == "__main__":
RunJavaClass().run()