Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:25:26+00:00 2026-06-12T06:25:26+00:00

The following java snippet calls a jni function Java_org_suhail_keylogger_HelperClasses_NativeMethods_unregisterHook : private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)

  • 0

The following java snippet calls a jni function Java_org_suhail_keylogger_HelperClasses_NativeMethods_unregisterHook :

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    jMenuItem1.setEnabled(false);
    jMenuItem2.setEnabled(true);
    try {
       System.loadLibrary("Dll_PKeylogger"); // Load the dll written to listen to the tapping of keys
       nativeMethods.initializeJNIVars(); // called upon the object of a class named NativeMethods
    }catch(Exception exc) {
        exc.printStackTrace();
    }
}

NativeMethods (class,whose object is used to call a JNI C method above) :

public class NativeMethods {

  public native void initializeJNIVars();
  public native void unregisterHook();

  public void displayKeyStrokes() { // FUNCTION THAT IS CALLED BACK FROM JNI C CODE
    System.out.println("Java Message : A Key has been pressed");
  }
}

JNI C method, called by the java code :

void Java_org_suhail_keylogger_HelperClasses_NativeMethods_initializeJNIVars
(JNIEnv *env, jobject obj) {
  jclass cls = (*env)->GetObjectClass(env,obj);
  callBackToDeliverKeyStroke = (*env)->GetMethodID(env,cls,"displayKeyStrokes","()V");
  object = (*env)->NewGlobalRef(env,obj);
  if(object == NULL | callBackToDeliverKeyStroke == NULL | cls == NULL) {
     printf("Initialization error...One of the variable is Null\n");
  }
 }

Method in the same module as the above method that calls the java function:

static LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
  JNIEnv *Env;
  (*Env)->CallVoidMethod(Env,object,callBackToDeliverKeyStroke); 
  // I have initialized object and callBackToDeliverKeyStroke in the above method
}

As the execution reaches the last point of execution i.e the function just mentioned above JVM crashes. Why is that ? Where have I made a mistake ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:25:28+00:00Added an answer on June 12, 2026 at 6:25 am
    JNIEnv *Env;
    (*Env)->CallVoidMethod(Env,object,callBackToDeliverKeyStroke);
    

    Env is not initialized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following snippet: import java.util.*; public class EqualsOverload { public static void main(String[]
The following method: private void startServer() { // snippet that starts the server on
Consider the constant in the following Java snippet : public class ConsumerServiceTestFixture { private
I'm trying to convert following java snippet to Xtend, but i couldn't able to
I have the following snippet of java code: File directoryToMoveTo = new File(file.getParent()+_TEMP); boolean
I need the java code snippet for the below logic: Following is a string
Let's look at the following code snippet in Java. package division; import java.math.BigDecimal; final
The following snippet from RuntimeUtil.java from jlibs guarantees GC that garbage collection is done.
The following java code prints Hello World on my co-worker's computer: public void testJDBC()
I have user-extensions.js that contain the following code of snippet: Selenium.prototype.doTypeRepeated = function(locator, text)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.