Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Make New Java Object In JNI

Thread view: 
res7cxbi@verizon.net - 27 Jan 2006 06:03 GMT
Im experimenting with this JNI thingy here....

I want to try to make an AudioFormat object (as a jobject of course)
and pass that to java.

In the JNI book from Sun it says that you need to get the class that
you will make instances from (FindClass), get the constructor
(GetMethodID), then finally use NewObject to get the jobject and return
it. Correct me if im wrong

The Constructor i want to use in AudioFormat looks like this:

AudioFormat(AudioFormat.Encoding encoding, float sampleRate, int
sampleSizeInBits, int channels, int frameSize, float frameRate, boolean
bigEndian)  

What do i do with the AudioFormat.Encoding argument?
Gordon Beaton - 27 Jan 2006 06:58 GMT
> Im experimenting with this JNI thingy here....
>
[quoted text clipped - 5 lines]
> (GetMethodID), then finally use NewObject to get the jobject and
> return it. Correct me if im wrong

That's about right.

A tip is to use "javap -s MyClass" to determine the correct method and
constructor signatures to use in e.g. GetMethodID().

Note too that you must include any package name when you specify the
class, in a slightly different format than you're used to, e.g.:

  jclass cls = (*env)->FindClass(env, "java/lang/String").

> The Constructor i want to use in AudioFormat looks like this:
>
[quoted text clipped - 3 lines]
>
> What do i do with the AudioFormat.Encoding argument?

If you need to pass an object (such as AudioFormat.Encoding) to any
constructor or method, then of course you need to start by creating
(or obtaining) one of those before you can invoke the constructor or
method itself.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

res7cxbi@verizon.net - 28 Jan 2006 02:39 GMT


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.