Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Frameworks etc.



"Matthew D. Hancher" <email@hidden> wrote:

>Is there a way to embed my .jar and .jnilib files in a framework so
>that other people can use them simply by including the framework in
>an Xcode project? This is easy for native libraries, but I can't
>get it to work for Java libraries.

I wouldn't bother doing a framework. I think it will be more portable if
you just distribute the JAR and JNI-lib as-is, with instructions on how to
use it in various IDE's, or even in Ant or make or command-line scenarios.

If XCode is anything like Project Builder, it's dead simple to compile
against additional jars. Just drag them into the project. CodeWarrior is
essentially the same.

You might include directions on where to look in XCode or PB to confirm
that the jar's been handled correctly, but this is no more difficult than
adding a framework to a project, and far more portable.

If you don't have access to other IDE's, enlist people who do have access
to tell you what to write in your instructions for use.

Note that compiling against a JNI-lib is unnecessary. There is nothing in
the file that is needed to compile a Java program against, even if the
method being called is a native method. All that's needed to compile is
the JAR-file.


I suggest compiling the distributed jar with as low a class-file
version-number as possible, so it can be used as-is as widely as possible.
Earlier compilers will not recognize later version-numbers, nor will
earlier JVMs run classes with later version-numbers. If you don't know
about class-file version-numbers, see:

<http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/javac.html#crosscomp-optio
ns>

<http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html>

<http://www.javaworld.com/javaqa/2003-05/02-qa-0523-version_p.html>

The summary is simply this:
Java 1.1 platform: 45.3-45.65535
Java 1.2 platform: 45.3-46.0
Java 1.3 platform: 45.3-47.0
Java 1.4 platform: 45.3-48.0


>More generally, where does System.loadLibrary() look for libraries?

It looks where it's told. It's told by the property "java.library.path",
supplemented by the Java extensions directories named in "java.ext.dirs".
AFAIK this is true on all platforms.

In app-bundled Java apps, the "java.library.path" is automatically assigned
a value that includes the Contents/Resources/Java directory within the
app-bundle itself.

Cocoa-Java apps DO NOT get this automatic inclusion of
Contents/Resources/Java, so loading JNI-libs in them is more problematic.
I solved the problem generically by writing the LibLoader class and putting
it into the public domain. The latest rev of LibLoader can be obtained
here:
<http://www.amug.org/~glguerin/sw/#authkit>

You have to grab the whole distro; I didn't split LibLoader out separately.


>Is there a general document somewhere that describes best practices
>for releasing Java classes to other developers, rather than directly
>building an application?

Not that I know of. All it really takes is a little common sense and an
understanding of how you use third-party library jars yourself.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.