njtbx-icon
Netcdf-Java Toolbox
previous Getting Started
Quick Tutorial Next

 
 
Environment Setup

Before using NJ toolbox (njTBX) you need to set up the Java environment and Matlab path.

  • Setup Matlab Java classpath
    • Locate the directory where you have downloaded NJ Toolbox jar files (toolsUI.jar & njTools.jar).
    • For Matlab 7+:
    • In Matlab, type "edit startup.m" and add the following lines (modified for the actual location of your jar files):
      javaaddpath('<your_full_path_here>\toolsUI-<version>.jar','-end');
      javaaddpath('<your_full_path_here>\njTools-<version>.jar','-end');
    • For Matlab 6 or 6.5:
    • Type "edit classpath.txt" in Matlab, add the above jar files to the list.
    • If you have Matlab 2008a or older, fix Matlab's java classpath. In Matlab, type "edit classpath.txt" and delete this line $matlabroot/java/jarext/mwucarunits.jar and save your changes. For Linux/Unix users: If you can't edit the system classpath.txt file, then copy it to your home directory and make the edit there. Matlab looks first for classpath.txt in your home directory, so it will use your edited version.
    • Remove any older versions of toolsUI & njTools jar files from the java classpath

  • Setup Matlab path
    • In matlab, locate the root folder where you have download the toolbox. Here you will find a script 'njtbxpath.m'. This is a convenience script, which lists required njTBX path(s) (absolute) to be added to the matlab search path. Add the path manually using matlab set path user interface or using 'addpath' command in your startup.m.

      An example shown below, where njTBX was downloaded in the root folder C:\skbhate\dev\usgs\matlab\m_cmg\new_branch\njTools\', and then 'njtbxpath' script was executed.
    • >> njtbxpath
      -------------------- njTBX-2.0 --------------------------------
       
      >>>>> Following directories must be added to the matlab search path in order for toolbox to run properly
       
      C:\skbhate\dev\usgs\matlab\m_cmg\new_branch\njTools\
      C:\skbhate\dev\usgs\matlab\m_cmg\new_branch\njTools\examples
      C:\skbhate\dev\usgs\matlab\m_cmg\new_branch\njTools\njFunc
      C:\skbhate\dev\usgs\matlab\m_cmg\new_branch\njTools\njTBX-2.0
      C:\skbhate\dev\usgs\matlab\m_cmg\new_branch\njTools\njTBX-2.0\Utilities
       
      
      Locate "Seawater" and "RPSStuff" directories on your system, which you must have downloaded earlier and add to matlab search path.
      These directories are only required for demos, and are NOT required for njTBX to function properly.
    • After adding the required directories to the matlab search path, exit and restart Matlab.
    • Type "javaclasspath" in Matlab. You should see the two jar files you added (along with all the Java stuff that comes with Matlab).
    • Type 'path' to see toolbox directories are successfully added.

  • Quick Tests
    • In matlab, try these commands in order.
    • >> ncRef = 'http://coast-enviro.er.usgs.gov/thredds/dodsC/bathy/crm_vol1.nc';  % Access an OpenDAP Data URL
      >> [data,geo] = nj_subsetGrid(ncRef,'topo',[-70.9 -70.1 41.15 41.65]);         % Select a lon/lat subset of variable "topo"
      >> imagesc(geo.lon,geo.lat,data); axis xy                                      % Plot it up
    • See if you can access njTBX help and demos in matlab. In matlab, select 'Start -> Toolboxes -> njTBX -> Help' to open njTBX help. Check screengrab of accessing help and demos.

  • If you encounter errors, refer to the 'troubleshooting' page.

 

previous Getting Started
Quick Tutorial Next
© 2006-2009   Mississippi State University   • License Terms   • Credits