Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create simple NFC program using java?

Tags:

java

nfc

open-nfc

I'm a newbie learning java and nfc. Actually I really need some help about my homework "NFC programming". I try this tutorial http://open-nfc.org/wp/editions/sdk-edition/creating-a-java-example/ and I still get this error msg:

Start failed !
NfcException : Error while starting the NFC Manager - Caused by NFC error DRIVER
at org.opennfc.NfcManager.start(Unknown Source)
at org.opennfc.NfcManager.getInstance(Unknown Source)
at example.Example.main(Example.java:26)
Exception in thread "main" java.lang.IllegalStateException
at org.opennfc.NfcManager.stop(Unknown Source)
at example.Example.main(Example.java:36)

Actually, what I want to run is this example code by open-nfc

NfcManager mgt = NfcManager.getInstance(null);
try {
  System.out.println(mgt.getProperty("open_nfc.version"));
  System.out.println(mgt.getProperty("nfcc.firmware_version"));
} finally {
  try {
    mgt.stop();
  } catch(NfcException e) {
    System.out.println("Error :" + e.getMessage());
  }
}

I've already start the connection center, nfc simulator, and server porting. And I have a device QPROX QP3000, already connected to my PC. I'm using eclipse juno and windows 7.

like image 289
pricillia Avatar asked Aug 10 '12 04:08

pricillia


People also ask

How do you write NFC codes?

To simply write to one blank NFC tag, make sure all of these options are unchecked. Finally, select “Write” at the bottom of the screen and tap the back of your phone to a blank NFC tag as if you were going to read it. This writes the URL to the tag. Congratulations, you've just encoded your first NFC tag!


1 Answers

The line calling NfcManager.getInstance(null) fails. Are you sure that NfcManager.getInstance() requires a null pareameter?

After that, calling mgt.stop() fails again with an java.lang.IllegalStateException , maybe because it's not started.

like image 190
Esteve Avatar answered Oct 10 '22 14:10

Esteve