[kepler-dev] Build Broken (by MatlabExpression.java?)

Christopher Brooks cxh at eecs.berkeley.edu
Mon Apr 24 17:59:03 PDT 2006

Using Runtime and Process will likely work fine.  I think the problem
has to do with how the binaries that are loaded by JNI are created.
The problem started appearing under Windows with cygwin with gcc-3.2.
I think the problem is more associated with cygwin than with gcc.
There is a longish message in ptolemy-hackers,

at http://groups.google.com/group/comp.soft-sys.ptolemy/browse_thread/thread/2c2093bbcd3af95d/28b132dc5abba5cd?lnk=st&q=jni+cygwin+ptolemy-hackers&rnum=1#28b132dc5abba5cd

The real solution under Windows appears to be to create a launcher program

A quick test is to run
cd $PTII
cd ptolemy/jni/test

Usually the tests will fail under Windows with gcc after gcc-3.2
If you trash your cygwin installatino and install the cygwin from
then the tests pass

I looked at the Mathworks pages and indeed Matlab can call Java code,
but it looks like to call Matlab from Java, one must use JNI, which
is what we do.  Oh well.

My one concern is that each time your actor fires, it execs a separate
Matlab process.  This could be slow.  However, under Cygwin at least
it works :-)

I'd like to see this Cygwin/JNI problem solved, but have not had the
time.  I think it requires creating a launcher to launch Ptolemy
or Kepler.



    My actor uses the Runtime and Process classes, however they themselves 
    use builtin JNI functions.
    If you can get my more info on invoking matlab without JNI that'd be great.
    I'm not sure exactly what you mean when you say JNI is broken under 
    windows cygwin. i can run my actor fine from cygwin, it's just a shell 
    after all and uses the same version of java that the rest of the system 
    uses. Maybe it's just that i'm not familiar with the environment you're 
    using it in tho.
    Christopher Brooks wrote:
    > Hi Tristan,
    > The Ptolemy MatlabExpression actor uses the JNI to communicate with
    > Matlab.  I don't think a separate process is invoked.  
    > I have not looked at Matlab lately, though Ernesto Wandeler recently
    > told me he had been able to invoke Matlab via Java and not use
    > JNI.
    > JNI under Windows Cygwin is utterly broken.   JNI using Microsoft
    > VC++ works.
    > _Christopher
    > --------
    >     My bad with that. I always figured that that java compliance settings
    >     eclipse meant that the code would compile under 1.4 (or maybe it does
    >     and i'm doing something wrong). I've modified the actor now and compi
    >     it using 1.4 to make sure it works, and will commit it again later on
    >     today (when i'm 100% sure it wont break anything :)).
    >     I've looked into the java interfaces that come with matlab, and as fa
    >     as i can tell they're not much use to us.
    >      From what i've managed to figure out, they just allow people to writ
    >     java classes for use inside matlab's own jvm (i.e. the classes must b
    >     called from inside matlab), and don't do anything when run from a 
    >     standard jvm.
    >     If anyone knows any different, please let me know. I'm not a big fan 
    >     the whole spawning additional processes to preform these tasks, and e
    >     less of having to parse text output to decipher the results. But for 
    >     i don't know of any other way of doing this.
    >     --Tristan
    >     Christopher Brooks wrote:
    >     > BTW - The Ptolemy Matlab expression actor uses JNI to communicate
    >     > with Matlab.  I believe there is now a pure Java Matlab interface
    >     > which is much more robust than JNI.  I would support tossing the
    >     > Ptolemy Matlab expression actor for a non-JNI Matlab actor.
    >     > 
    >     > Nandita create a MatlabStartScript utility that looks like it start
    >     > a remote Matlab process using Runtime.getRuntime().exec().  
    >     > I'm not so sure if this is the right thing, since it starts a 
    >     > separate process each time.  It might be better to have a 
    >     > more integrated actor?  However, I'm not sure what the plan is
    >     > for this actor, so there could easily be good uses for it.
    >     > 
    >     > 
    >     > _Christopher
    >     > 
    >     > --------
    >     > 
    >     >     MatlabExpression code is apparently keeping the nightly build f
    >     >     compiling. Would however is working on this please fix ASAP!
    >     >     
    >     >     (And is this different that the Matlab actor in PTII ? (which w
   e coul
    >    d 
    >     >     put in Kepler)
    >     >     
    >     >     Dan Higgins
    >     >     NCEAS
    >     >     _______________________________________________
    >     >     Kepler-dev mailing list
    >     >     Kepler-dev at ecoinformatics.org
    >     >     http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/k
    >    dev
    >     > --------
    >     > _______________________________________________
    >     > Kepler-dev mailing list
    >     > Kepler-dev at ecoinformatics.org
    >     > http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/keple
    >     > 
    >     -- 
    >     Tristan King                            | Ph: (07) 4781 6911
    >     DART project team                       | Email: Tristan.King at jcu.edu
    >     James Cook University                   | Web: http://dart.edu.au
    >     Townsville QLD 4814                     | http://plone.jcu.edu.au/dar
    >     Australia                               |
    > --------
    Tristan King                            | Ph: (07) 4781 6911
    DART project team                       | Email: Tristan.King at jcu.edu.au
    James Cook University                   | Web: http://dart.edu.au
    Townsville QLD 4814                     | http://plone.jcu.edu.au/dart/
    Australia                               |

More information about the Kepler-dev mailing list