Search code examples
javanfc

How do I open nfctools library in NetBeans?


Background: I am trying to write a simple application in Java (to run on a Win10 laptop) to read the first 256 bytes of a NFC EEPROM (ST M24SR64-Y). The NFC EEPROM is in a hardware device my company makes.

That project is not going so well (I will probably be posting about that issue soon) but I am trying to figure out what I'm doing wrong in this simple application.

The Problem: I cannot load the nfctools library source code in NetBeans 7.4. The project name has a [unloadable] tag next to the project name in the Projects window. Right-clicking the project and selecting "Resolve Project Problems" provides the following Description:

Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-ssh:2.2 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven.wagon:wagon-ssh:jar:2.2, org.codehaus.plexus:plexus-utils:jar:1.1: The repository system is offline but the artifact org.apache.maven.wagon:wagon-ssh:jar:2.2 is not available in the local repository. @ 

I have looked for a NetBeans plugin called wagon or wagon-ssh but didn't have any luck. I also could not find anything starting with plex.

I really just want to use the nfctools library but I'm getting errors and cannot find any info as to why so I'm trying to look at the source code.

I would also rather be able to build the nfctools library than have to rely on an already compiled version from the nfctools-examples repo.

Note: I did try NetBeans 11.3 just in case the nfctools library requires a newer version of NetBeans but I got the same error as in 7.4. I'm using NetBeans 7.4 just because my "Teach Yourself Java" book uses 7.4 and it's easier to follow the examples that way.

The nfctools and nfctools-examples on my machine are clone'd from the Git repo.


Solution

  • Quick Fix

    The project will indeed say "unloadable" when you first open the project, because you have not yet downloaded the Maven dependencies for the project.

    Just press F11 in NetBeans to build the project (or click on the hammer icon).

    This will automatically download all missing dependencies, as defined in the project's POM.

    Detailed Steps

    In case the above quick fix did not work - here are the steps from the start:

    I assume you are referring to the NFC Tools here: https://github.com/grundid/nfctools

    Go to the web page and click on the green "clone or download" button.

    I chose "download zip" just because I did not want to clone.

    I am using Windows 10.

    (I am using Java 11 - but I assume that is less critical.)

    Unzip the zip file "nfctools-master.zip" (I recommend using the free 7-Zip tool to do this).

    I am using Apache NetBeans 11.1:

    In NetBeans, go to File > New project > choose Category: Java with Maven, and also Project: Project with Existing POM.

    Click on Finish.

    Using the "Open Project" dialog in NetBeans, navigate to the unzipped folder "nfctools-master". The entry should have the Maven "Ma" icon, instead of the plain folder icon.

    Click on Open project.

    It will say "unloadable" at this point.

    Hit F11 to build the project.

    When I do this, the build ends with the following output in the NetBeans console:

    Reactor Summary for NFC Tools for Java 1.0-SNAPSHOT:
    
    NFC Tools for Java ................................. SUCCESS [  1.777 s]
    nfctools-api ....................................... SUCCESS [  2.736 s]
    nfctools-ndef ...................................... SUCCESS [  2.691 s]
    nfctools-core ...................................... SUCCESS [  3.968 s]
    nfctools-p2p ....................................... SUCCESS [  2.920 s]
    
    BUILD SUCCESS
    

    Also, take a look at the contents of the pom.xml file that comes with the project.

    In your new "NFC Tools for Java" project, open the Project Files folder and then open pom.xml. You will see references to one of the items you mention in your question:

    wagon-ssh

    That's all taken care of by Maven.

    Tool Examples

    I assume that is a similar process to the above (I have not not tried this one).

    https://github.com/grundid/nfctools-examples

    Hope that helps - good luck.

    If you have more specific questions, after this, I recommend you create a new specific question - but check if it has already been asked & answered first.

    Opening from Git Clone

    In NetBeans choose File > Open Project.

    Navigate to the "nfctools" directory that was created when you ran git clone https://github.com/grundid/nfctools.

    When you select the nfctools directory, you will be given the option to open other required projects:

    • nfctools-api
    • nfctools-core
    • nfctools-ndef
    • nfctools-p2p

    Apart from that, you should see the same end result as when you used the zip file.