[kepler-dev] JNI under Windows

Christopher Brooks cxh at eecs.berkeley.edu
Sun Jun 11 12:42:22 PDT 2006

Hi Dan,

Thanks for the feedback on the Kepler situation.

Interestingly, for Ptolemy II 5.0, I had tried compiling the 
Ptolemy Matlab actor with MSVC and ended up getting somewhat
better stability, but I still saw some crashes, both with
InstallAnywhere and when running under Cygwin. 

Under InstallAnywhere, if I opened up lots of models and then tried
to use the MSVC compiled Matlab interface, then I think I would 
get a crash.  However, if I opened up the MSVC compiled interface
before opening up lots of models, then I would usually be able
to run the model once.  Sometimes I would get a crash on the
second run.  It would be interesting to try this with the R
actor and see what happens.  The easiest way to open up lots
of models is by using following the Ptolemy copyright link 
until the "expand files" page comes up.

I've not yet seen any crashes with $PTII/jni/launcher/launcher.exe,
though I have not yet tried the run lots of models tests.

For us, the Viptos interface requires gcc, so we can't easily
go with MSVC.  Also, I'd like to be able to support JNI code
compiled with gcc if possible.  I've cleaned up the JNI ui
a little, but it is still buggy.



        Kepler does use JNI for several actors (but not for our R based 
    actors!). JNI is used for the 'GARP' actors and the gdal gis actor. We 
    have not had any particular problem with the JNI interface, but note 
    that we are not running under cygwin for these jni-based actors. 
    Instead, they were compiled under Microsoft Visual C. I didn't do the 
    original programming, but I am under the impression that the original 
    programmers were unable to get JNI working on Windows with cygwin/gcc, 
    but that it was straightforward with the MS compiler. The main problem 
    now is getting platform specific code running on Windows, Mac OS X, and 
    Linux. (The new Intel-based Macs has added some complexities to the 
    Christopher Brooks wrote:
    > Ok, I got around to trying the Java Launcher for JNI
    > programs that was described in
    > http://elliotth.blogspot.com/2005/08/porting-jni-code-to-win32-with-cygwi
    > I downloaded some C code from
    > http://software.jessies.org/terminator/
    > checked it in to ptII/jni/launcher and after a little cleaning, I
    > was able to run the meaningOfLife demo under Windows.
    > The launcher program is a C program that invokes
    > Java that then allows Java to invoke JNI programs
    > under Cygwin.  Without this launcher program, under Windows
    > with Cygwin, any Ptolemy model that uses the JNI actors or
    > the Ptolemy Matlab actor exits violently.
    > The launcher program takes an argument that names the 
    > class with a slash separated name.  Also, thee class path
    > must be passed in as a property.
    > For example, to run "vergil -jni", we do:
    > $PTII/jni/launcher/launcher -Djava.class.path="$PTII" ptolemy/vergil/Verg
   ilApplication -jni
    > The launcher can be used to solve the problems we were
    > having with Viptos under Windows.
    > Also, it should help with the Matlab interface.
    > One side effect is that since we now need a custom launcher for the
    > Matlab actor, the InstallAnywhere LaunchAnywhere binary is probably
    > not going to cut it for us. This means will need a new installer.  If
    > we don't need the Matlab actor, then InstallAnywhere can still be
    > used.
    > Interestingly, Kepler uses JNI in a few places, most notably with R.
    > I'm surprised that there have not been problems like what we've had
    > with simple JNI actors and with the Matlab actor.  More research 
    > is in order, I'd like to be sure that we understand this.
    > More cleanup of the launcher code is in order.  I need to look
    > at the copyright etc.
    > Also, the Ptolemy JNI UI is a mess, it would be worth fixing this
    > because I keep getting questions about it.  Removing it from the tree
    > is an option, but the problem is that then people download Ptolemy II
    > 4.0 and ask questions about it, which is basically unsupportable since
    > I'm always saying, "Upgrade".
    > _Christopher
    > _______________________________________________
    > Kepler-dev mailing list
    > Kepler-dev at ecoinformatics.org
    > http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev

More information about the Kepler-dev mailing list