Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Calling Java method from c

813103Apr 15 2011 — edited Apr 20 2011
Hi. THis is my problem:

I want to write applet that draws amplitude of a line-out, meaning it draws what you hear. I have the c++ part that reads samples and stores them in a buffer alredy written and the java part that calculate FFT writen as well. Now when the buffer is full c++ dispatche the event and i grab those samples and now i my problem. How to write function that passes that array to the java class. For clarity.

Java code:
public class applet extends Applet
{
init(){...}
public native void start();
public native void stop();

public void setSamples(byte[] array)  //<-- this is the method that i need to call from c++
}
C++ code:
void fullBuffer(char *array)//<-- this function is run when buffor is filled
{
...
lEnv->CallVoidMethod(class_to_be_called,mid_byteAray,jbyteArray); //<-- this of cousre doesn't work but i need somthing with the same effect
}

Comments

Suri
Hi,

Maximum size for VARCHAR2 is 4000. So you cant add 32767 characters to a variable which you have defined with VARCHAR2 datatype.

Below will work
DECLARE
  LEN1  NUMBER;
  STR   VARCHAR2(32767);
BEGIN
  
  STR := RPAD('*', 4000, '*');
  
  SELECT LENGTH(STR) INTO LEN1 FROM DUAL;
  DBMS_OUTPUT.PUT_LINE('LEN1: '||LEN1);
 
END;
Thanks,
Suri

Edited by: Suri on Aug 8, 2012 1:50 PM

Edited by: Suri on Aug 8, 2012 1:52 PM
APC
In your first example the database engine overrode your length for the RPAD() call with the SQL limit (4000 characters). In your second example you presented the engine with a 32K string and it hurled. This is because the engine hasn't been programmed to truncate a string which is too long.

If anything I think the first example is inconsistent. Certainly that behaviour is [url http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions147.htm#i78723]not documented.

Cheers, APC
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 18 2011
Added on Apr 15 2011
6 comments
370 views