dev setup question for moving from CLI to IDEs

János janos.lobb at yale.edu
Thu Apr 26 11:04:39 PDT 2007


Hi,

Until now I used command line tools compile Java and C code.  Here is  
the directory content of this mini jni project:

-rw-r--r--   1 janos  janos     505 Apr 23 13:08 BarJNI$1.class
-rw-r--r--   1 janos  janos    6825 Apr 23 13:08 BarJNI.class
-rw-r--r--   1 janos  janos     430 Mar 14 17:16 BarJNI.h
-rw-r--r--   1 janos  janos   11158 Apr 23 13:08 BarJNI.java
-rw-r--r--   1 janos  janos   11158 Apr 23 12:59 BarJNIC.c
-rwxr--r--   1 janos  janos    2377 Nov 10 05:43 barcode.h
-rwxr-xr-x   1 janos  janos  425268 Mar 19 05:46 libbardecode.dylib

barcode.h and libbardecode.dylib was provided by the vendor.  I use a  
simple text editor to edit both the Java and the C code.

If I want ot compile Java I just do:
bml0042:~/XCodeProjects/barjni janos$ javac BarJNI.java

If I want to compile C I just do:

bml0042:~/XCodeProjects/barjni janos$  gcc -dynamiclib -o /Volumes/ 
Home/janos/XCodeProjects/Nativelibs/libBarJNIC.jnilib  
libbardecode.dylib BarJNIC.c

and it works marvelously.  My dilemma is that the Java code will be  
part of a much bigger project and that project is managed and  
developed using IntelliJ IDEA.  Sooner or later someone  wants also  
to compile the C portion from XCode and create the BSD library.  So  
the question is what kind of directory structure should I have that  
when I compile in XCode the resulting library will be seen by the  
Java class ?

To start with I created an ~/IdeaProjects/bar folder and its content  
looks:

drwxr-xr-x   4 janos  janos    136 Apr 25 13:51 CPart
-rw-r--r--   1 janos  janos    516 Apr 24 16:25 bar.iml
-rw-r--r--   1 janos  janos  15662 Apr 24 16:25 bar.ipr
-rw-r--r--   1 janos  janos  28054 Apr 24 17:07 bar.iws
drwxr-xr-x   4 janos  janos    136 Apr 24 16:59 classes
drwxr-xr-x   6 janos  janos    204 Apr 24 16:51 src


In the src directory are the renamed Java sources - /and the C source  
and header files momentary/:

bml0042:~/IdeaProjects/bar janos$ ls -l src
total 64
-rw-r--r--   1 janos  janos    470 Apr 24 16:53 IFEBarcodeReader.h
-rw-r--r--   1 janos  janos  10541 Apr 24 16:48 IFEBarcodeReader.java
-rw-r--r--   1 janos  janos  11178 Apr 24 16:54 IFEBarcodeReaderC.c
-rwxr--r--   1 janos  janos   2377 Nov 10 05:43 barcode.h

and I plan to move the C parts into CPart.  The question is where the  
vendor supplied barcode.h header and libbardecode.dylib dylib files  
should go, so that I can see it when I compile the C in Xcode and the  
compiled wrapper dlyb will be visible to the Java Class ?  Right now  
if I compile and run the Java in IntelliJ IDEA I am getting the class  
not found message:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no  
IFEBarcodeReaderC in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
	at java.lang.Runtime.loadLibrary0(Runtime.java:822)
	at java.lang.System.loadLibrary(System.java:992)
	at IFEBarcodeReader.<clinit>(IFEBarcodeReader.java:350)

Process finished with exit code 1

So looks like that whereever XCode will create the  
FEBarcodeReaderC.dylib, that directory has to be added to the  
java.library.path so IDEA will see it.

Are there any settings for it in Xcode and IDEA I can setup ?

Thanks ahead,

János


More information about the MacOSX-dev mailing list