• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Java program using Cocoa Classes dying...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Java program using Cocoa Classes dying...


  • Subject: Java program using Cocoa Classes dying...
  • From: John Haager <email@hidden>
  • Date: Tue, 21 May 2002 09:23:34 -0700

I have a Java program which I am attempting to add some Cocoa Foundation classes into. Specifically, I would like to use NSDictionary. My Java class has a native method which reads a string containing a serialized NSDcitionary, and then passes this string back up into a Java callback method. This method then attempts to recreate the NSDictionary using the NSPropertyListSerialization.propertyListFromString() static method call.

For some reason, calling this method causes a java.lang.UnsatisfiedLinkError: propertyListFromString error. I have attached a sample program which demonstrates the problem. To run it, you can run 'java -classpath JavaUsingCocoa.jar:/System/Library/Java JavaUsingCocoa' from the command line.

-> John Haager <-

------------------------
JavaUsingCocoa.java:

//
// JavaUsingCocoa.java
//
import java.util.*;
import com.apple.cocoa.foundation.* ;

public class JavaUsingCocoa
{
private void callback ( String data )
{
try
{
NSDictionary dict =

(NSDictionary)NSPropertyListSerialization.propertyListFromString ( data ) ;
}
catch ( Throwable t )
{
t.printStackTrace () ;
}
}

public native void callforward ( String data ) ;

public static void main (String args[])
{
System.loadLibrary ( "JavaUsingCocoa" ) ;

JavaUsingCocoa obj = new JavaUsingCocoa () ;
// insert code here...
obj.callforward ("Hello World!");
}
}


------------------------
JavaUsingCocoa.h:

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <JavaVM/jni.h>
/* Header for class JavaUsingCocoa */

#ifndef _Included_JavaUsingCocoa
#define _Included_JavaUsingCocoa
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: JavaUsingCocoa
* Method: callforward
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_JavaUsingCocoa_callforward
(JNIEnv *, jobject, jstring);

#ifdef __cplusplus
}
#endif
#endif

------------------------
JavaUsingCocoa.cpp

/*
* JavaUsingCocoa.cpp
* JavaUsingCocoa
*
* Created by John Haager on Tue May 21 2002.
* Copyright (c) 2001 __MyCompanyName__. All rights reserved.
*
*/

#include "JavaUsingCocoa.h"

JNIEXPORT void JNICALL Java_JavaUsingCocoa_callforward
(JNIEnv * env, jobject jthis, jstring jdata)
{
jclass thisClass ;
jmethodID callback_mid ;

thisClass = env->GetObjectClass ( jthis ) ;
callback_mid = env->GetMethodID ( thisClass, "callback", "(Ljava/lang/String;)V" ) ;

env->CallVoidMethod ( jthis, callback_mid, jdata ) ;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Prev by Date: Re: HELP!! [self needsHelpWith:strings];
  • Next by Date: Background task and logout and login
  • Previous by thread: Re: HELP!! [self needsHelpWith:strings];
  • Next by thread: Background task and logout and login
  • Index(es):
    • Date
    • Thread