Getting started
What you need
Section titled “What you need”- JDK 25 and a Maven project configured to compile for Java 25.
- A PC/SC-compatible NFC reader with its driver and smart-card service available.
- A writable NTAG215 tag with a supported NDEF layout. A factory-formatted empty tag is suitable.
You can compose and encode a message offline while your hardware is disconnected.
1. Add SocialCard to Maven
Section titled “1. Add SocialCard to Maven”Add the dependency inside the <dependencies> section of your pom.xml.
<dependency> <groupId>io.github.vijiyarathan-rithush</groupId> <artifactId>socialcard</artifactId> <version>1.0.3</version></dependency>Use <maven.compiler.release>25</maven.compiler.release> in your Maven properties and confirm that mvn -version shows JDK 25. SocialCard on Maven Central
2. Write a link and read it back
Section titled “2. Write a link and read it back”Place the tag on the reader. Save the example as src/main/java/FirstTag.java and run its main method in your IDE. Writing replaces the tag’s existing NDEF message, so use a tag whose contents you can overwrite.
import com.rvi.service.IReaderService;import com.rvi.service.ReaderService;
public final class FirstTag{ public static void main(final String[] args) { try (final IReaderService reader = ReaderService.create()) { reader.connect(); reader.writeURI("https://rithush.dev"); System.out.println(reader.readURIs()); } }}With the tag still in place, the console prints a list containing the URL.
[https://rithush.dev]3. Understand each call
Section titled “3. Understand each call”ReaderService.create()selects the first available reader. With multiple readers, select one by name.connect()opens the card connection immediately. Put the tag on the reader before calling it.writeURI()creates a one-record NDEF message, writes it and verifies the data by reading it back.readURIs()reads the tag again and returns its URI records in order as strings.- The try-with-resources block closes the service and releases the connection, including when an operation fails.
Continue with How it works to follow the code path, or Troubleshooting if the reader or tag is unavailable.