Repository navigation
Expand file tree
/
Copy pathTestHDF4Link.java
More file actions
72 lines (60 loc) · 2.39 KB
/
Copy pathTestHDF4Link.java
File metadata and controls
72 lines (60 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/****************************************************************************
* NCSA HDF *
* National Comptational Science Alliance *
* University of Illinois at Urbana-Champaign *
* 605 E. Springfield, Champaign IL 61820 *
* *
* For conditions of distribution and use, see the accompanying *
* java-hdf5/COPYING file. *
* *
****************************************************************************/
/*
* This program tests the linking and calling of the HDF-5 library.
*
* The purpose is to help debug the installation of the JHI-5.
*/
import ncsa.hdf.hdflib.*;
public class TestHDF4Link {
static public void main( String []args )
{
String libPath = System.getProperty("java.library.path",null);
if ( libPath == null ) {
System.out.println("ERROR: No library path set.");
System.exit(1);
}
System.out.println("Searching for libraries in: "+libPath);
System.out.flush();
System.out.println("Test load of Java HDF Interface: ");
try {
System.loadLibrary("jhdf");
} catch (Throwable t1) {
System.out.println("Exception loading Java HDF Interface: "+t1);
System.exit(1);
}
System.out.println("OK. (libjhdf.so)");System.out.flush();
String [] vs = new String[1];
vs[0] = new String("");
int vers[] = new int[3];
boolean ok = false;
System.out.println("\nTest call to HDF Library:");
try {
ok = HDFLibrary.Hgetlibversion(vers, vs);
} catch (Throwable t3) {
System.out.println("Exception calling HDF Library: "+t3);
System.exit(1);
}
System.out.println("OK. (HDFLibrary.getlibversion "+vers[0]+"."+vers[1]+"."+vers[2]);System.out.flush();
System.out.println("\n");System.out.flush();
System.out.println("Path is Correct: \n\t"+libPath);
System.out.println("Try to create file: \n");
int res = 0;
try {
res = HDFLibrary.Hopen("test.hdf", HDFConstants.DFACC_CREATE);
} catch (Throwable t4) {
System.out.println("Exception creating file: "+t4);
System.exit(1);
}
System.out.println("OK.");System.out.flush();
System.out.println("\n");System.out.flush();
}
}