I want to connect magnetic card reader, send commands and get responses with Java (COM Port) in Windows XP. I have .h
file & dll
. I want use dll
functions. How can I connect or send device?
Asked
Active
Viewed 544 times
1
-
possible duplicate of [java api to send file through serial port](http://stackoverflow.com/questions/2003821/java-api-to-send-file-through-serial-port) – trashgod Jun 01 '11 at 05:22
-
@trashgod, I want send command and RECEIVE responses, not send file – totali Jun 01 '11 at 05:34
-
@trashgod, but the DLL probably has high level functions specific for his reader which he would be missing in those libraries. – Eelke Jun 01 '11 at 05:40
-
Ah, I see; now it makes sense. – trashgod Jun 01 '11 at 05:44
2 Answers
3
You will need to use JNI (Java Native Interface), google it for details. You probably will have to write some wrappers around the DLL in C first before JNI can use it.

Eelke
- 20,897
- 4
- 50
- 76
-
+1. Can I solve my problem with Java APIs (Javax.comm or RXTX, not using JNI or write some code in C)? – totali Jun 01 '11 at 05:50
-
@totali: I found @Eelke's comment and answer very helpful; I've clarified your question and up-voted the answer accordingly. When you have sufficient reputation, I urge you to do likewise. You may also want to review the [faq](http://stackoverflow.com/faq). – trashgod Jun 01 '11 at 06:00
-
@totali: using JNA as trashgod suggest in his answer shouldn't require any C but I have no experience with it. If you know the full serial protocol you can use any serial java communication library, see trashgods earlier comments. – Eelke Jun 01 '11 at 08:57