JavaCPP and JNI

stevel05

Expert
Licensed User
Longtime User
I've played with the Java Native Interface in the past with a little success but found it very cumbersome. I have just stumbled across JavaCPP, it says it works with Android too. I plan to investigate further when I get some time, I just wondered if anybody had used it already on either standard Java or Android.

I also found Java Native Access (JNA) that on first inspection looks like it may be a little like the B4A/B4J Java Object.

Both look very interesting.
 

agraham

Expert
Licensed User
Longtime User
I've not seen JavaCPP before but it looks a bit too "low level" for my taste. I would be quite happy to never have to look at another piece of C/C++ code again, let alone write in it! Nowadays I'm happier with managed code, C# or Java. I would have thought that JavaCPP would be only really useful where absolute performance or native API access is needed.

For native access from Java (only Win32 API as am solely a Windows person) I have looked before at JNA for Win32 access from Java code and it looks very promising although I haven't had any time so far to try playing with it. That link is an old link, the JNA project is now at version 4.0.0 and is now on Github https://github.com/twall/jna where the (quite informative) Javadoc and downloadable jars are located.
 

stevel05

Expert
Licensed User
Longtime User
Thanks Andrew, yes time is always the issue. Thanks for the new link, I'll have a look there.
 

birdwes

Member
Licensed User
Longtime User
Hi Andrew and Steve.

I'm going there into JNI.

I'm going to make demo from B4A to JNI and beyond (ARM assembler).

C is my native language. I don't do Java, which is one of the reasons I love B4A.

But I'm going lower, like my RasPBX g729a project. I am making a fixed point FFT spectrum analyser demo, which will be up here with full source code, ( as a precursor to the thing I need it for ).

My issue is that the app I want to release needs to run on the oldest most basic hardware and not get me a negative review in the play store.

My thinking is that if I can get good performance on a Raspberry Pi (ARM v6) then it should run on almost any android old phone/tab) that doesn't have the NEON extensions. My B4A app runs in realtime on the S3 but won't on the cheap AllWinner (which is why I bought it as a test device for £40).

I have to make it work on everything.


This is work in progress, but it's going well. Current benchmarks are approaching NEON like speeds in terms of relative CPU speed (though I'm cheating by using fixed point arithmetic)!

Raspberry Pi has single core 700 MHz ARM v6 processor.

Results:

100 x 4096 point transforms/sec
1.6 seconds for 10000 256 point transforms. (this will improve I hope)

This is a dual project though as it will be for the Raspberry Pi community too.

A credit to http://pulsar.webshaker.net/ must be mentioned.

Progress so far: http://pulsar.webshaker.net/ccc/sample-775e8972

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=33&t=43841
 
Top