Before writing the Native code, you will need to use javah
and
javap
to get information for the JNI native code.
native
keyword, you need to run javah
against the Java class files. Since the
tools uses the class files rather than the source files, you must run the Java compiler
before using the tool. The result of this is a C language header file (.h) that you
will use as the template for writing the native code.
javah -classpath target/classes uk.co.xfactorylibrarians.coremidi4j.CoreMidiClient \ uk.co.xfactorylibrarians.coremidi4j.CoreMidiDestination \ uk.co.xfactorylibrarians.coremidi4j.CoreMidiDeviceProvider \ uk.co.xfactorylibrarians.coremidi4j.CoreMidiDeviceInfo \ uk.co.xfactorylibrarians.coremidi4j.CoreMidiInputPort \ uk.co.xfactorylibrarians.coremidi4j.CoreMidiOutputPort \ uk.co.xfactorylibrarians.coremidi4j.CoreMidiSource
javap -s
against the Java class files to obtain the method signatures for
the Java methods. Once again, this must be run after compiling the Java source code and
before writing the C language code calling the JNI API.
Any changes to the signatures for any of the Java methods using the native
keyword may change the header file for all of the methods using the
native
keyword in that class.
The following is the set of Maven commands that I used to build the jar file.
mvn clean compile javadoc:javadoc package
I am currently using Javadoc to create documentation for the Java classes used in the application. The Javadoc tool is run as part of the Maven build process.
At this time, I am using Doxygen to create the documentation for the C language files. I have added a
Doxygen configuration file in the project directory (Doxyfile
), but you may need to make
some changes for your personal development environment.
See this page for information on how to install a snapshot jar file in your local repository so that you can use it. If the jar file was created by a recent version of Apache Maven, you can use the command
mvn install:install-file -Dfile=<path-to-file>
where
<path-to-file>
is the location of the jar file.
When I created my own snapshot build, I set the version to 1.1BR-SNAPSHOT
, so that the]
artifact can by retrieved as
<groupId>uk.co.xfactory-librarians<groupId>
<artifactId>coremidi4j</artifactId>
<version>1.1BR-SNAPSHOT</version>