DAP2 Protocol Java Software


Greetings,

This is a Java implementation of the OPeNDAP DAP2 Protocol.

In this file you will find:

Also included are:

We hope we hope you find this software useful, and we welcome your questions and comments.

To contact us, please email technical support: support@opendap.org

 


Dependencies

Java Virtual Machine

Java 2 Standard Edition (J2SE)

Minimum: Java 1.5
Recommended: Java 1.6.x

This software was developed and tested against the 1.6.0 release of the J2SE

3rd Party Libraries Required by the DAP2 Software

The core software depends on several third part libraries. All of these are included with the distribution (in the lib directory). These (should) be the ones that the code was compiled against for development and testing purposes.

It is possibly (in fact likely) that newer versions of these libraries are available from the various development teams that create these products. Replace them at your own risk.


Installation

Installation should be quite simple, just make sure that the dap2-x.x.x.jar file, along with the additional library jar files are your CLASSPATH in order for the DAP2 software to work.

Sanity Check In order to verify that you have the software and JVM sorted try the following in a shell(command line):



Note: This command was formulated for the dap2-1.0.0 release. If for some reason it doesn't work for you it may be possible that this part of the dopcumentation was not updated to reflect name changes or dependancies in the current release. The correct construction of this command to include as parameters to the classpath parameter ("-cp") the dap2 release jar file name followed a colon (":") followed by a colon sperated list of the every jar file name in the lib dir, as modeled above. The next parameter in the command is the full name of the class to run, in this case opendap.util.geturl.Geturl. This is followed by a switch indicating the type of DAP response to get, in the above example it's "-d" which tells Geturl to get the DDS response (there is a "-h" help option too). The final parameter is the data resource URL of a DAP2 dataset available over the internets, in the example above that's:

http://test.opendap.org:8080/opendap/data/nc/fnoc1.nc



Code Examples

There are two code samples provided in the distributions "src" directory. These should give you a simple road map for getting your java program to read DAP2 data. Please view the src/opendap/dap/DConnect2.java code as the best practice example. The simple main() method looks like this:
    public static void main(String[] args) {

        DConnect2 dc;

        for (String url : args) {
            try {
                System.out.println("");
                System.out.println("");
                System.out.println("########################################################");
                System.out.println("\nConnecting to " + url + "\n");

                // Make a new DConnect2 object for the dataset URL/file.
                dc = new DConnect2(url);

                System.out.println("\n- - - - - - - - - - - - - - - - - - -");

                System.out.println("Retrieving DDS:\n");
                DDS dds = dc.getDDS();
                dds.print(System.out);

                System.out.println("\n- - - - - - - - - - - - - - - - - - -");
                System.out.println("Retrieving DAS:\n");
                DAS das = dc.getDAS();
                das.print(System.out);



                System.out.println("\n- - - - - - - - - - - - - - - - - - -");
                System.out.println("Retrieving DDX:\n");
                dds = dc.getDDX();
                dds.printXML(System.out);


                System.out.println("\n- - - - - - - - - - - - - - - - - - -");
                System.out.println("Retrieving DATA:\n");
                dds = dc.getData("");
                dds.printVal(System.out, "");

                System.out.println("\n- - - - - - - - - - - - - - - - - - -");
                System.out.println("Writing DATA:\n");

                FileOutputStream fos = new FileOutputStream("dc2.out");
                DataOutputStream dos = new DataOutputStream(fos);
                dds.externalize(dos);

            } catch (Throwable t) {
                t.printStackTrace(System.err);
            }

        }

    }
The src/opendap/util/geturl/Geturl.java example utilizes the older (and less useful) opendap.dap.DConnect class.