0

I am working on a CDF(file mastercard uses) file parser in Java and I am using the API found here. In order to use this API you need the jar file..

I don't understand how I am getting this exception since it should be handled in the getFile() method.. I google'd around and I still don't understand what the issue is.. if anyone can point me in the right direction that would be great. By following the stacktrace.. to me it seems it's an issue with the library.

The link to the api is found here: http://cdf.gsfc.nasa.gov/cdfjava_doc/cdf34/

When trying to open a CDF file I am getting this error after running the program:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: no cdfNativeLibrary in jav
a.library.path                                                                       
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)                  
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)                          
        at java.lang.System.loadLibrary(System.java:1084)                            
        at gsfc.nssdc.cdf.CDFNativeLibrary.<clinit>(CDFNativeLibrary.java:47)        
        at gsfc.nssdc.cdf.CDF.open(CDF.java:426)                                     
        at gsfc.nssdc.cdf.CDF.open(CDF.java:385)                                     
        at FileModel.getFile(FileModel.java:21)                                      
        at FileModel.main(FileModel.java:9)  

Here is my source code:

import gsfc.nssdc.cdf.*;
import gsfc.nssdc.cdf.util.*;

public class FileModel
{

    public static void main(String[] args)
    {
        getFile();
    }

    public static void getFile()
    {

        try
        {
            CDF cdf = CDF.open("outbound_MidCycle_File.xml");
            //System.out.println(cdf.getID());
        }
        catch(CDFException e)
        {
            System.out.println("ERROR Cannot open CDF File");
        }
        catch(Exception e)
        {
            System.out.println("ERROR");
            System.out.println(e.getMessage());
            e.printStackTrace();
        }

    }

}

The commands I run are as follows:

javac -cp '.:cdfjava.jar' FileModel.java
java -cp '.:cdfjava.jar' FileModel
ryandawkins
  • 1,537
  • 5
  • 25
  • 38

3 Answers3

2

You still have to install the CDF Software Distribution on the system prior to using the API. Download the appropriate version from http://cdf.gsfc.nasa.gov/html/sw_and_docs.html and install it - that should clear up the "Native Library" issue (or at least did for me).

Mike
  • 21
  • 2
0

This doesn't solve your whole problem, but should solve some of the mystery:

UnsatisfiedLinkError is a Throwable, not an Exception. That's why you code isn't catching it. Replace catch(Exception e) with catch(Throwable e).

pamphlet
  • 2,054
  • 1
  • 17
  • 27
0

The CDF library you got is one we use in Space Physics, for a particular file format, and has nothing to do with

user186353
  • 21
  • 2