s-news
[Top] [All Lists]

calling Java from S-plus?

To: <s-news@lists.biostat.wustl.edu>
Subject: calling Java from S-plus?
From: "Zege, Andrew [EQTY]" <andrew.zege@citigroup.com>
Date: Thu, 6 Apr 2006 15:20:42 -0400
Thread-index: AcZZrzJlH43V4IyhQSKe3X7YIdepAQ==
Thread-topic: calling Java from S-plus?
I am experiencing serious problems with calling java methods from s-plus. Just 
to give the most 
trivial example, i have a Java class:
===========================================
public class ltt.splib.CollectionCaller{
        public static void writeDouble(double,String);
}
==========================================
I define s-plus function 

writeDouble<-function(d, dirname){
    .JavaMethod("CollectionCaller",
                "writeDouble",
                 "(D;Ljava/lang/String)V",
                 d, dirname)
                 
}
======

when i call it like
writeDouble(30.1,"somedirname")
I am getting a message:
==============================
Problem in .JavaMethod("ltt/splib/CollectionCaller",..: Illegal method 
descriptor "(D;Ljava/lang/String)V". 
==================

I don't get what is wrong. The java class is compliled and other objects in the 
same directory are found by s-plus.
What am i missing? I actually need to do something more involved in reality, 
namely call another function of the same java class which has a signature

public static void writeLTTData(double [][] data, String [] rownames, String [] 
dates, String dirname);

i defined my S-plus interface to it as
writeLTTData<-function(d, rownames, dates, dirname)
{
        .JavaMethod("ltt/splib/CollectionCaller", "writeLTTData", 
                
"([[D;[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V",
                d, rownames, dates, dirname)
}

every time i try to run this, using 
writeLTTData(d, dimnames(d)[[1]], dimnames(d)[[2]], someDir),
where d is S-plus matrix it crashes s-plus. I must be doing something seriously 
wrong. Am i correct
to assume that char vector is passed from S-plus to Java as array of strings 
and matrix is passed as two-dimensional array of doubles? I am using Splus 6 on 
Lunix






<Prev in Thread] Current Thread [Next in Thread>
  • calling Java from S-plus?, Zege, Andrew [EQTY] <=