Hi Tika users.
I'm having trouble importing tika .class files. I have written a basic
.java script that is saved in the same directory as toolsUI-4.3.jar .
I call the script at the command line as:
[abryant:~/tika/tika] abryant% javac -cp '.:toolsUI-4.3.jar'
NetDump_tikalist.java
Within that script I have the import commands:
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.Property;
Once I execute the script I get the errors:
NetDump_tikalist.java:11: package org.apache.tika.metadata does not
exist
import org.apache.tika.metadata.Metadata;
^
NetDump_tikalist.java:12: package org.apache.tika.metadata does not
exist
import org.apache.tika.metadata.Property;
The 'metadata' files are in:
/Users/annbryant/tika/tika/tika-core/target/classes/org/apache/tika/metadata
If I run the script with the two tika import commands commented out, it
works fine.
As a java beginner I'd appreciate any input on the behind-the-scenes action
that needs to take place to have scripts find tika .class files.
Many thanks!
Annie
*********************************SCRIPT*********************************
// NetCDF imports
import ucar.nc2.NetcdfFile;
import ucar.nc2.Attribute;
import ucar.nc2.Variable;
import ucar.nc2.Dimension;
import java.io.IOException;
import java.util.logging.Logger;
// Desired TIKA imports
import org.apache.tika.metadata.Metadata; // comment this out to get it to
run
import org.apache.tika.metadata.Property; // comment this out to get it to
run
public class NetDump_tikalist{
private static Logger log = Logger.getLogger("InfoLogging");
public static void main( String[] args ){
String name = "lsmask.nc.nc"; // NetCDF file
// NetCDF file downloaded from:
ftp://ftp.cdc.noaa.gov/Datasets/noaa.oisst.v2/lsmask.nc
System.out.println(name); // Print File
try {
NetcdfFile ncFile = NetcdfFile.open(name); // Attempt to open
NetCDF File
System.out.println("Dimensions:");
for (Dimension dim : ncFile.getDimensions()){
System.out.println(dim);
}
System.out.println("Variables:");
for (Variable var : ncFile.getVariables()){
//Property property = resolveMetadataKey(var.getName());
//**need tika import
if (var.getDataType().isString()){ // check if data type
in the variable is a string
System.out.println(var);
//metadata.add(property, attr.getStringValue());
//**need tika import
}
else if (var.getDataType().isNumeric()){ // check if data
type in the variable is a number
//int value = var.getNumericValue().intValue();
//metadata.add(property, String.valueOf(value));
//**need tika import
System.out.println(var);
}
}
}
catch (IOException ioe){
log.info("error");
}
}
}
/* SCREEN OUTPUT WITH SUCCESSFUL RUN
>From the command line:
[abryant:~/tika/tika] abryant% javac -cp '.:toolsUI-4.3.jar'
NetDump_test.java
[abryant:~/tika/tika] abryant% java -cp '.:toolsUI-4.3.jar' NetDump_test
Output will mimic that of NCdumpW:
Dimensions
lon = 321;
lat = 161;
time = UNLIMITED; // (1 currently
Variables
float lat(lat=161);
:units = "degrees_north";
:long_name = "Latitude";
:actual_range = 20.0f, 60.0f; // float
float lon(lon=321);
:units = "degrees_east";
:long_name = "Longitude";
:actual_range = 220.0f, 300.0f; // float
double time(time=1);
:units = "hours since 1-1-1 00:00:00";
:long_name = "Time";
:actual_range = 0.0, 0.0; // double
:delta_t = "0000-00-01 00:00:00";
:avg_period = "0000-00-01 00:00:00";
short lsmask(time=1, lat=161, lon=321);
:long_name = "Land Sea Mask";
:valid_range = -1S, 1S; // short
:actual_range = -1.0f, 1.0f; // float
:add_offset = 0.0f; // float
:scale_factor = 1.0f; // float
:missing_value = 32766S; // short
:var_desc = "Land-sea mask";
:dataset = "CPC Unified Gauge-Based Analysis of Daily Precipitation over
CONUS";
:level_desc = "Surface";
:statistic = "Other";
*/
--
------------------------------------------------------------------------------------------
Ann Bryant Burgess, PhD
University of Southern California
Postdoctoral Fellow
Los Angeles, CA
Alaska Science Center/USGS
Anchorage, AK
Cell: (585) 738-7549
Office: (907) 786-7059
Fax: (907) 786-7150
E-mail: [email protected]
Office Address: 4210 University Dr., Anchorage, AK 99508-4626
-------------------------------------------------------------------------------------------