Does LevelDB support java? - java

I want to know if LevelDB supports java ?
Where can i get the LevelDB. There are no files under http://code.google.com/p/leveldb/

You can use the https://github.com/fusesource/leveldbjni java library which gives you a Java API to LevelDB via JNI.
There is also a Pure Java implementation of LevelDB available at https://github.com/dain/leveldb
Both the JNI wrapped and pure Java implementation implement the same interface classes so it's really easy to switch between the two.

LevelDB currently does not ship with JNI bindings, but you can wrap your own JNI binding around the file db/c.h via SWIG and the like.

You can have a try of leveldb-java. This is a pure Java version of LevelDB.

From looking at the source, i can say that it doesn't support java.
For the source use svn checkout http://leveldb.googlecode.com/svn/trunk/ leveldb-read-only

Related

Generate Java classes from .dll

I have a device which I want to access from java. The only way to do this is using a dll library provided by the manufacturer. I have read about JNI, JNA etc. and maybe there is a tool outside which analyses the dll and generates the Java classes automatically.
Does anybody know a way of doing this?
You need something like this - JNAerator can "compile" native headers in order to generate JNA mappings, with some limited C++ support.
Finally we used jawin to generate the Java classes for accessing the the .dll. The jawin typebrowser tool was the only one that could handle the C++ .dll we were trying to access.
Unfortunately the jawin project is no longer developed. The last version is dated to early 2005.

how to write python wrapper of a java library

How can we write a python (with CPython) binding to a Java library so that the developers that want to use this java library can use it by writing only python code, not worrying about any Java code?
You could try this way:
Use Jython instead of CPython to write Python code http://www.jython.org.
Integrate Jython code with Java code through Apache Bean Scripting Framework http://commons.apache.org/bsf/
If you definitely need to use CPython, then Apache Trift could be interesting for you: http://thrift.apache.org/ So you could make additional scalable abstraction layer and integrate your Java code with different languages (not only Python)
If you need a really low-level interface you could look at JNI http://java.sun.com/docs/books/jni/ for investigation. But I think it will take a lot of time to integrate your code with CPython using JNI.
I've used JPype in a similar instance with decent results. The main task would be to write wrappers to translate your java api into a more pythonic api, since raw JPype usage is hardly any prettier than just writing java code.

How to use a C API in Java? JNI?

I'm building a J2EE project, in which I would like to use an API which is only available in C.
I was thinking of using JNI to do so, but after a quick look at this tutorial, it looks that I in order to use JNI, I need to have the source code (.c files) to compile some kind of "JNI library".
In my case, the API only comports the .h with the signature of all the methods, and the already compiled .dll (or .so).
How could I do this?
Thank you!
JNA is a JNI-based library that allows calling normal C functions without needing a JNI-specific wrapper for each one.
Check out JNA. It allows you to use the .DLL directly. All you need to do is write a Java interface with the same functions you need from the .DLL.
Create a small C wrapper for the native library, compile this to a .dll/.so.
For each needed function in the existing C api, create one JNI-compliant C function which simply calls the real API.
JNI offers a pretty low level API for interfacing your Java code with native code. If you are OK with shelling out money, Jinvoke looks like a pretty good alternative which doesn't require you to write any C/C++ code. The plus here is that you get full paid support. If you don't require it, you can go with JNA. Anything but JNI IMO...

managing un-managed codes in JAVA?

like in C#,
Is it possible to manage un-managed in JAVA?
I want to use system dll like kernel32.dll, user32.dll or gdi32.dll.....
Java can call native code via the Java Native Interface (JNI). Java Native Access (JNA) is a wrapper around JNI that makes it more convenient to use.
Sure. Have a look at JNI.
Some useful links to get you started:
Wikipedia: Java Native Interface
Java Native Interface: Programmer's Guide and Specification
jGuru: JNI FAQ Home Page
Yes, no problem. Have a look at JNI, the java native interface.

Calling Java library from Objective C on Mac

I want to create native Mac OS X application using Cocoa + Objective C but I need to connect to proprietary data source, and for this, owner of the data source only provides Java library. So I need to somehow import this Java library into my project and call functions on its Java classes.(Or create java wrapper around this library and then call my wrapper from objective-C).
Now, how can I do this? Quick google search leads me to JNI but I haven't found any good and actual(current) article/tutorial. I would really need some HOW TO article, how to load this java library, start VM if needed, and how to create java objects and call functions on them. Really something simple and I can move from there. Thanks.
Just to clarify, I repeat: I WANT to call Java functions from Objective-C, I do NOT want to call native functions from Java.
You're probably looking for the Invocation API, a little-known corner of Java Native Interface (JNI) which allows you to load the Java runtime in-process.
That said, you might have an easier time of it with a Java service application that communicates with your Objective-C application over network sockets.
You're looking for the Java-Objective C bridge, try looking at this article or on Apple's developer site. Be aware it is deprecated, that is it isn't being kept up to date with changes to Cocoa. But if you're just using it for an API passing standard Java datatypes you should be OK.

Categories