function fileinfo = nc_info_java ( ncfile )
%
% This function returns the same metadata structure using the java 
% API.  The "Varid" field is set to [] since it does not have the
% same meaning in java as the C API.

import ucar.nc2.dods.*     % import opendap reader classes
import ucar.nc2.*          % have to import this (NetcdfFile) as well for local reads
                           % Now that's just brilliant.  


fileinfo.Filename = ncfile;


if snc_is_url ( ncfile )
	try
		jncid = DODSNetcdfFile(ncfile);
	catch
		strformat = '%s:  DODSNetcdfFile failed on %s, ''%s''.\n';
		error ( strformat, mfilename, ncfile, lasterr ); 
	end
else
	try
		jncid = NetcdfFile(ncfile);
	catch
		strformat = '%s:  NetcdfFile failed on %s, ''%s''.\n';
		error ( strformat, mfilename, ncfile, lasterr ); 
	end
end


%
% Get the Dimensions
dim_count = 0;
root_group = jncid.getRootGroup();
dims = root_group.getDimensions();
dims_iterator = dims.listIterator();
while 1

	%
	% This throws an exception when we've reached the end of the list.
	try
		jDim = dims_iterator.next();
	catch
		break;
	end

	dim_count = dim_count + 1;

	mdim.Name = char ( jDim.getName() );
	mdim.Length = jDim.getLength();
	mdim.Dimid = dim_count - 1;
	mdim.Record_Dimension = jDim.isUnlimited();

	Dimension(dim_count,1) = mdim;

end

if dim_count == 0
	fileinfo.Dimension = [];
else
	fileinfo.Dimension = Dimension;
end



%
% Get the datasets.
var_count = 0;
j_var_list = root_group.getVariables();
j_var_iterator = j_var_list.listIterator();
while 1

	%
	% This throws an exception when we've reached the end of the list.
	try
		jvarid = j_var_iterator.next();
	catch
		break;
	end

	var_count = var_count + 1;


	mDataSet = snc_java_varid_info ( jvarid );

	DataSet(var_count,1) = mDataSet;

end
if var_count == 0
	fileinfo.DataSet = [];
else
	fileinfo.DataSet = DataSet;
end


%
% Get the attributes
j_att_list = root_group.getAttributes();
fileinfo.Attribute = snc_java_bundle_atts ( j_att_list );



close ( jncid );

return
