import com.tableausoftware.TableauException;
import com.tableausoftware.common.Type;
import com.tableausoftware.extract.Extract;
import com.tableausoftware.extract.Row;
import com.tableausoftware.extract.Table;
import com.tableausoftware.extract.TableDefinition;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class TestTableau {
public static void main(String[] args) throws IOException {
//delete existing extract file
String extractFile = "extract.tde";
deleteFile(extractFile);
try (Extract extract = new Extract(extractFile)) {
//create table definition
TableDefinition tableDef = new TableDefinition();
int columnCount = 100;
for (int i = 0; i < columnCount; i++) {
tableDef.addColumn(Integer.toString(i), Type.UNICODE_STRING);
}
//create a table
Table table = extract.addTable("Extract", tableDef);
//create a sample document
//reuse the document for each row to minimize the non-tableau CPU and memory consumption
Random random = new Random();
List<String> rowData = new ArrayList<>();
for (int i = 0; i < columnCount; i++) {
rowData.add(Integer.toString(random.nextInt()));
}
long startTime = System.nanoTime();
System.out.println("Populating table...");
//populate the table
int tableRows = 4000000;
for (int i = 0; i < tableRows; i++) {
//convert input document to tableau row
Row row = new Row(tableDef);
for (int j = 0; j < rowData.size(); j++) {
row.setString(j, rowData.get(j));
}
//add the row to the table
table.insert(row);
}
long endTime = System.nanoTime();
System.out.println(String.format("Total time (ms): %s", (endTime - startTime) /
1000000));
} catch (TableauException e) {
e.printStackTrace();
}
}
private static void deleteFile(String file) {
File extractFile = new File(file);
if (extractFile.exists()) {
extractFile.delete();
}
}
}
当我运行代码时出现异常:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'TableauExtract': The specified module could not be found.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:194) at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:283) at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:244) at com.sun.jna.Native.register(Native.java:1065) at com.tableausoftware.extract.Extract.(Unknown Source) at TestTableau.main(TestTableau.java:21)
我已将以下 jar 文件添加到构建路径:
tableauextract.jar jna.jar tableaucommon.jar
如何解决这个问题?
最佳答案
如果您已将库添加到构建路径中,您是否尝试再次清理并构建项目?
关于java - 线程 "main"java.lang.UnsatisfiedLinkError : Unable to load library 'TableauExtract' : The specified module could not be found 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45084486/