Java JNA call to C++ dll works from Netbeans but not when .jar is invoked from command line -
my java program calls dll compiled in c++ using jna. dll receives java int
, double
values arguments. works fine when run netbeans, when invoke java .jar program command line, c++ program receives rubbish: i.e. int equal 1 received 64562352. when program run repeatedly sending int 1 java, c++ dll receives different numbers: 65631824, 66011704,....
i use windows 7, netbeans 7.0.1, java 1.7.0_01, microsoft visual c++ 2008, jna 3.3.0 (b0).
the relevant code is:
java:
public interface cliblp extends library { enter code here`public double vectorc (int tipoprob, int nvar, double numero); } public class llamadorlp { public static void main(string[] args) { int tipoprob = 1; int nvar = 1000; double numero = 1.5; double total = clib.vectorc(tipoprob, nvar, numero); }
c++:
extern "c" __declspec(dllexport) double vectorc (int tipoprob, int nvar, double numero); double vectorc(int tipoprob, int nvar, double numero) { printf("estoy en la funciĆ³n c!\n"); printf("tipoprob=%d\n",tipoprob); printf("nvar=%d\n",nvar); printf("numero=%6.1f\n",numero); return total; }
many thanks, mario.
i found out making silly netbeans mistake there no trouble jna invocation.
when running netbeans selected correct class run. when running command line, .jar used class main class results unpredictable. in word dll called different classes. set correct main class netbeans project properties , went righ: both results, running form netbeans , command line identical.
so jna ok.
Comments
Post a Comment