|
JNAeratorFAQ
JNAerator's Frequently Asked Questions
Featured
What is JNAerator ?JNAerator (pronounce ‘generator’) is a tool that parses C / C++ & Objective-C sources (headers) and generates the corresponding BridJ, JNA and Rococoa Java interfaces. This makes it easy to call large native libraries from Java. By default, JNAerator creates ready-to-use compiled JARs with self-extractible native libraries. These JARs also contain the generated sources, which contain full JavaDoc that retains the comments from the original headers. How to use MyLib.dll with MyLibHeader.h header from Java ?java -jar jnaerator.jar MyLib.dll MyLibHeader.h will produce MyLib.jar How to use MyLib.dll without headers from Java ?This is experimental and has big limitations, but simple cases should work : java -jar jnaerator.jar MyLib.dll MyLibHeader.h -scanSymbols will produce MyLib.jar How to use the output of MySolution.sln from Java ?First make sure you compiled your solution in Release for both Win32 and Win64 targets, if needed. java -jar jnaerator.jar MyLibHeader.sln will produce MySolution.jar How to include self-extracting libraries binaries in JAR outputs ?This is already done by default, provided that you add the paths to all needed libraries binaries to JNAerator's command line. Where are libraries looked for at run-time ?If you've opted for library bundling within the JNAerated JAR (see previous question), your libraries are shipped with your JAR and need not be pre-installed on the system. JNAerator will extract them in the directory .jnaerator/extractedLibraries under the user's home directory and will use them directly from there. For a library with name 'foo' (which shared library files are named 'foo.dll', 'libfoo.so', 'libfoo.dylib'...), JNAerator's runtime will try the following PATH values, in order :
For more information please see JNA's documentation and CommandLineOptionsAndEnvironmentVariables. How to use MacOS X frameworks from Java ?For most commonly used public frameworks, you should simply download Rococoa and use it alone. If you need frameworks not covered by Rococoa, wish to use private headers and / or frameworks or ObjectiveC libraries for which no headers are available, then you should use JNAerator : java -jar jnaerator.jar -framework Framework1 -framework Framework2 lib1.dylib lib2.dylib... What command-line options and environment variables are available ?sta There are quite a few of them : CommandLineOptionsAndEnvironmentVariables Is there a mailing list where I can ask for some help ?For now, JNA's users mailing list is THE place to be. JNAerator stalls / hangs forever when fed with large headersThis appears to be a bug coming from its ANTLR parser, which does not react well to low-memory conditions. The parsing takes ages and seems to never end. You can solve this by increasing the maximum memory allocated to the JVM : java -Xmx1g -jar jnaerator.jar your-arguments-here If this does not help, please file a bug with an execution trace you'll capture from jconsole. There's no .java outputUse the -noComp -noJar switches (see CommandLineOptionsAndEnvironmentVariables for more options) There's no output at all, or with no useful symbols and functionsPlease read TroubleShootingJNAeration I have many command line arguments, can I write them in a file ?You can create a file with the extension .jnaerator that will contain all your command line arguments. Please read JNAeratorFiles for more information. Can I JNAerate multiple libraries at the same time ?Sure thing, you can chain multiple -library switches : -library Mine1 mine1.h libmine1.so -library Mine2 mine2.h libmine2.so -library Mine3 mine3.h libmine3.so Here's a real-world example : OpenCV4Java's config.jnaerator file. My header includes other headers, what should I do ?You just need to make sure that JNAerator's integrated preprocessor can resolve these includes. JNAerator has a list of include paths that can be extended using the standard -I switch (which most if not all compilers accept) : adding "-Ipath" to the command line will add path to the include directories. For instance, if one of your headers includes core/structs.h and you know that this header is located in /usr/myTestLib/include/core/structs.h, you need to add the following argument to the command line (or to your .jnaerator file) : -I/usr/myTestLib/include Note that JNAerator should have default include paths for the most common system headers. For more details on JNAerator's command line switches, see CommandLineOptionsAndEnvironmentVariables. I found a bug in JNAerator. Where shall I file it ?The Issues section is here for that. | |
The command for generating without headers is the same as with headers... It doesn't seem correct...
@ricardocampos Thank you for pointing it out, I've updated the command :-)
How I can generate wrap classes for JNA, if I have to header files(CustomerServerAPI.h and CustomerServerTypes?.h)? Can I give 2 header files to jnaerator?
@tkachuk.g yes of course, just put the two of them in the command line. They'll be parsed in the order you specify them.
Hello, I have a Delphi DLL (without any header files) ... how can I create a Java wrapper? Regards Andreas
Hi
I tried using JNAerator with maven mvn com.jnaerator:maven-jnaerator-plugin:jnaerate without success. I tried maven 2.2.1 and 3.0. And even setting Java heap memory to 1GB set MAVEN_OPTS=-Xmx1256m The same error Exception for E:\\Workspaces\\workspace...\\jnaretor\\.....h at line 1619:java.util.concurrent.ExecutionException?: java.lang. Exception: java.lang.OutOfMemoryError?: Java heap space java.util.concurrent.ExecutionException?: java.lang.Exception: java.lang.OutOfMemoryError?: Java heap space
Update.
Finally I succeeded with latest version 0.9.8 using maven. Surprisingly result is better then in JNAerator Studio or command line, and is correct for my case.
</project>