Friday, January 31, 2014

netbeans 7.4 - cmd is not recognized

maven project created in netbeans 7.4 cannot be run because of the follow error:

'cmd' is not recognized as an internal or external command, operable program or batch file."

Try adding this "C:\Windows\System32" to the environment varialbes and restarting netbeans.

Thank you:
http://stackoverflow.com/questions/14491928/cmd-not-recognised-in-maven



Thursday, January 16, 2014

Java JNI - passing arrays in and out of native calls

Problem:
I needed return as a function parameter an array of int plus the length of the array.

#commands relative to src
//compile class
javac -classpath .  com/wmmnpr/c2/Pm4.java

//create header file
javah -classpath .  com.wmmnpr.c2.Pm4


//compile c code
g++  -fpic  -W1,--add-stdcall-alias -I /usr/jdk/jdk1.6.0_06/include -I /us
r/jdk/jdk1.6.0_06/include/solaris -shared -o libpm4lib.so  com_wmmnpr_c2_P
m4.c

//compile class using native method(driver)
javac -classpath .  com/wmmnpr/app/CallLib.java

//loading of library
in file:

 static {

        System.loadLibrary("pm4lib");

 }

//name of library on disk in working directory (/sa-home/pennoye/jni/src)
libpm4lib.so

//run driver
java -classpath /sa-home/pennoye/jni/src  -Djava.library.path=/sa-home/pen
noye/jni/src com.wmmnpr.app.CallLib

The code for the project is here: