Skip to content
Discussion options

You must be logged in to vote

The way to access JNIEnv from ctypes using JPype would be the following....

import jpype
import ctypes
from ctypes import POINTER, byref, c_void_p, c_int, c_char_p
import os

jpype.startJVM()

########################################
# PAIN STARTS HERE

# Define JNI constants
JNI_VERSION_1_6 = 0x00010006

# libjvm was already loaded
libjvm = ctypes.CDLL(None)  # Access already loaded library

# Define JavaVMAttachArgs structure
class JavaVMAttachArgs(ctypes.Structure):
    _fields_ = [
        ("version", c_int),
        ("name", c_char_p),
        ("group", c_void_p)
    ]

# Define JNI types
jint = ctypes.c_int
jlong = ctypes.c_longlong
jfloat = ctypes.c_float
jdouble = ctypes.c_double
…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
6 replies
@Thrameos
Comment options

@Lqm1
Comment options

@Thrameos
Comment options

@Lqm1
Comment options

@Thrameos
Comment options

Comment options

You must be logged in to vote
1 reply
@Lqm1
Comment options

Answer selected by Lqm1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Question on how to use JPype
2 participants