boa tarde a todos..
estou desenvolvendo um aplicativo para trabalhar o a dll bemafi32.dll da bematech
a bematech fornece um .jar para trabalhar com o jni mas eu quero trabalhar com o jna
e fiz as seguintes classes:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testedll;
import com.sun.jna.win32.StdCallLibrary;
/**
*
* @author Admin
*/
public interface BematechJNA extends StdCallLibrary {
public int Bematech_FI_LeituraX();
public int Bematech_FI_VerificaEstadoImpressora(Integer ack,Integer st1,Integer st2);
public int Bematech_FI_ModeloImpressora(String modelo);
public int Bematech_FI_DataHoraImpressora(String data,String hora);
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testedll;
import com.sun.jna.Native;
/**
*
* @author Admin
*/
public class LeituraX {
public LeituraX() {
BematechJNA bematechjna = (BematechJNA)
Native.loadLibrary("c:\\java\\testedll\\BEMAFI32.DLL", BematechJNA.class);
System.out.println(bematechjna.Bematech_FI_LeituraX());
String modelo=" ";
bematechjna.Bematech_FI_ModeloImpressora(modelo);
System.out.println(modelo);
String data="";
String hora="";
bematechjna.Bematech_FI_DataHoraImpressora(data,hora);
System.out.println(data+hora);
int ack = 0,st1 = 0,st2=0;
bematechjna.Bematech_FI_VerificaEstadoImpressora(ack, st1, st2);
System.out.println("retornos:");
System.out.println(ack+" "+st1+" "+st2);
}
public static void main(String[] args) {
LeituraX leix = new LeituraX();
}
}
estou utilizando o emulador da bematech
na linha 38 no main da classe LeituraX
eu instancio a classe onde vai executar o construtor
e neste momento ele executa a a linha
System.out.println(bematechjna.Bematech_FI_LeituraX()) que me retorna 1 ou seja que conseguiu emitir a leitura x normalmente,
ou seja a dll foi carregada e esta executando sem nenhum problema, e no emulador aparece a leitura x emitida...
ate ai sem problema...
o problema se encontra no restante dos metodos que solicitam informacoes da impressora...
os dois primeiros:
bematechjna.Bematech_FI_ModeloImpressora(modelo);
bematechjna.Bematech_FI_DataHoraImpressora(data,hora);
me retornam as variaveis modelo, data e hora
sem nenhuma informacao...
o terceiro:
bematechjna.Bematech_FI_VerificaEstadoImpressora(ack, st1, st2);
da o erro abaixo:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x04728fe7, pid=4356, tid=4392
#
# JRE version: 7.0_09-b05
# Java VM: Java HotSpot(TM) Client VM (23.5-b02 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [BEMAFI32.DLL+0x58fe7] Bematech_FI_CancelCheckPrint+0x564a8
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\java\TesteDll\hs_err_pid4356.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
alguem sabe me explicar o que esta acontecendo...
desde ja agradeco: