java – How to uUsing Cocoa sleep notification for an external applica

I have a Java application that is made for Windows, Ubuntu, and Mac OS Systems. Applicaton completely goes numb when Mac goes to sleep. This doesn’t happen for other OS’s.

I need corresponding data in my app database to make up for the time it sleeps so the app needs to receive some data to get an idea of the time the system went to sleep.

The Objective C code I have written here I suppose will notify every time the system goes to sleep and wakes up.

My concern is how I will integrate this code with my java code so that the app gets the data it collects. I thought this is written in C and even tried dll programming.

I need help to integrate this function to my application.

- (void) receiveSleepNote: (NSNotification*) note
{
    NSLog(@"receiveSleepNote: %@", (note name));
}
 
- (void) receiveWakeNote: (NSNotification*) note
{
    NSLog(@"receiveWakeNote: %@", (note name));
}
 
- (void) fileNotifications
{
    //These notifications are filed on NSWorkspace's notification center, not the default
    // notification center. You will not receive sleep/wake notifications if you file
    //with the default notification center.
    (((NSWorkspace sharedWorkspace) notificationCenter) addObserver: self
            selector: @selector(receiveSleepNote:)
            name: NSWorkspaceWillSleepNotification object: NULL);
 
    (((NSWorkspace sharedWorkspace) notificationCenter) addObserver: self
            selector: @selector(receiveWakeNote:)
            name: NSWorkspaceDidWakeNotification object: NULL);
}