java-dev
[Prev] Thread [Next] | [Prev] Date [Next]
Re: Xcode -> Java Native Interface -> Eclipse Sandro Sabatini Fri Jul 11 12:03:02 2008
Hi Matthew,your java source file Grabber.java that says it's in package edu.salk.snl.micrimap must be located in the path src/edu/salk/snl/micrimap, _not_ directly in src/
Saba Am 16.05.2008 um 02:06 schrieb Matthew Grivich:
Hello Michael (and others),This was the problem, though it took me some time to figure out. The xcode project was using the default package. The eclipse project was not. Woe unto me for changing two things at once. I had to change the C function names to this form:JNIEXPORT jint JNICALL Java_edu_salk_snl_micrimap_Grabber_OpenCamera(JNIEnv *env, jobject this, jstring cameraFilePathString)where the package is edu.salk.snl.micrimap, the class is Grabber, and the method is OpenCamera. Of course in the process of fixing the eclipse build, I broke the xcode build. Does anyone know how to generate a java package in xcode? It should be trivial, but unfortunately it does not seem to be. Currently my file Grabber.java is in MainFolder/src/. src is a blue folder. Yes, I did remember thepackage edu.salk.snl.micrimap; line at the top of the .java file. It seems to be being ignored. Thanks. Matthew Michael Stringer wrote:Matthew,Check that your headers and C functions are correct. Run 'javah' on the class that defines the native method calls to get what Java is looking for.Michael On 14 May 2008, at 20:46, Matthew Grivich wrote:Hello All, I am attempting to write a frame grabber and camera control program for Macintosh. The frame grabber in question uses a C api. I havewritten a simple java wrapper for this using the java native interface (JNI), entirely in Xcode. However, Xcode does not have very good Javasupport, so I'd like to write the Java portions of the program inEclipse, and the C and java native interface portions in Xcode. I amusing Xcode 3.0, OS 10.5.2, a dual processor G5, and Eclipse 3.3.2.First, I will say what works. In Xcode: File -> New Project -> Java -> Java JNI Application. Makes jni version of hello world, works fine. I copy the generated headers folder and the .jnilib to a jnilib folder inmy eclipse project (EclipseTest/jnilib). In eclipse: Right clickproject name (EclipseTest) -> properties -> source -> EclipseTest/ src ->Set Native library location to EclipseTest/jnilib. I copy the .java file from the Xcode project to the Eclipse Project src folder, bycreating a new java file in Eclipse, and copy-pasting the text of thefile from Xcode. Everything works.In Xcode: I start with the jni hello world. I add the C files from the third party api. I write the appropriate wrapper code to do some simple operations with the camera (open, snap, and close) from java. In orderto get things to link properly, I add a build phase to the JNILibtarget. This build phase is Link Binary With Libraries. Right click this, then Add -> Existing Frameworks -> select the five necessary third party frameworks. These frameworks are located in /Library/ Frameworks.This all works. Now, I will get to what doesn't work. I transfer camera .jnilib andheaders folder over to an eclipse project. When I try to run it, I getStarted applicationException in thread "main" java.lang.UnsatisfiedLinkError: OpenCameraat edu.salk.snl.micrimap.Grabber.OpenCamera(Native Method) at edu.salk.snl.micrimap.Grabber.main(Grabber.java:80) When I don't make the jnilib available, it givesException in thread "main" java.lang.UnsatisfiedLinkError: no Grabber injava.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753) at java.lang.Runtime.loadLibrary0(Runtime.java:822) at java.lang.System.loadLibrary(System.java:993) at edu.salk.snl.micrimap.Grabber.<clinit>(Grabber.java:25) So I know that it is finding the .jnilib. My belief is that it is not finding the third party frameworks. However, I have not found the "make it work" button. Any assistance would be much appreciated. Thanks. Matthew _______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list ([EMAIL PROTECTED]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/michael.stringer%40yuuguu.com This email sent to [EMAIL PROTECTED]_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list ([EMAIL PROTECTED]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/mgrivich%40salk.edu This email sent to [EMAIL PROTECTED]_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list ([EMAIL PROTECTED]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/sabax%40gmx.net This email sent to [EMAIL PROTECTED]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list ([EMAIL PROTECTED]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/alexiscircle%40gmail.com This email sent to [EMAIL PROTECTED]
- Xcode -> Java Native Interface -> Eclipse Matthew Grivich
- Re: Xcode -> Java Native Interface -> Eclipse Michael Stringer
- Re: Xcode -> Java Native Interface -> Eclipse Matthew Grivich
- Re: Xcode -> Java Native Interface -> Eclipse Sandro Sabatini <=
- Re: Xcode -> Java Native Interface -> Eclipse Matthew Grivich
- Re: Xcode -> Java Native Interface -> Eclipse Moises Lejter
- Re: Xcode -> Java Native Interface -> Eclipse Greg Guerin
- Re: Xcode -> Java Native Interface -> Eclipse Matthew Grivich