On 1/12/06, RedBugz Software <[EMAIL PROTECTED]> wrote:
>
> I'm an m2 newbie trying to implement our JNI library building via the
> native-maven-plugin. I've grabbed the latest source and built it and
> installed it.
>
> How are these projects normally set up? I'm trying to get the Sun JNI
> Tutorial example working before I tackle our actual project. I initially
> setup a POM with 2 modules, test-jni-java and test-jni-native, but I end
> up
> with circular dependencies, since the java code needs to be compiled
> before
> javah can be run and the native lib compiled, but then the java code has a
> dependency on the compiled native lib.
root
pom.xml <--- includes jni-java and jni-native modules
jni-java <-- a jar packaging
jni-native <---- native packaging( dll ) make your it depends on
test-jni-java
> Any suggestions on how to setup this project? Any example projects out
> there
> I can look at?
>
> Additionally, the native:javah goal is not running correctly. It doesn't
> seem to be generating a classpath entry. I get this:
> [INFO] C:\j2sdk1.4.2_09\jre\..\bin\javah.exe -d
> C:\src\WORKSP~4\test-jni\test-jn
> i-native\src\main\native -classpath HelloWorld
> Error: Class HelloWorld could not be found.
>
> I don't see from the documentation where I specify the classpath. I
> cheated
> and added an additional className entry:
> <classNames>
> <className>test-jni-java/target/classes</className>
> <className>HelloWorld</className>
> </classNames>
classname is wrong, it just be java format com.xuy.classname
Will fix up the example to be clearer.
> which generates the correct command line for javah, but is clearly the
> wrong
> way to do it.
>
> Finally, while I'm compiling on Windows for now (MinGW gcc), I'll need to
> compile on Linux and Solaris eventually. I don't see how one sets this up
> to
> run on the appropriate platform, since win32 is specified in the POM
> itself.
For each platform, your will need to create a project for native compile
root
jni-java
native
pom.xml <--- use profile to trigger native build depending on os
src <------ put all your common native source here
win32
linux
....
I never tested with MinGW gcc, but accouding to Sun, you need msvc 6.0 to to
do JNI stuff
thanks,
> Logan Allred
Enjoy
Dan