native library can be loaded correctly now.
This commit is contained in:
parent
ab2b24319f
commit
973e47475b
|
@ -21,13 +21,21 @@
|
|||
<source>target/bench4q-monitor.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>WindowsMonitor/Release/Monitor.dll</source>
|
||||
<outputDirectory>/lib/x86</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>WindowsMonitor/Release/Native.dll</source>
|
||||
<outputDirectory>/lib/x86</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>WindowsMonitor/x64/Release/Monitor.dll</source>
|
||||
<outputDirectory>/lib</outputDirectory>
|
||||
<outputDirectory>/lib/x64</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>WindowsMonitor/x64/Release/Native.dll</source>
|
||||
<outputDirectory>/lib</outputDirectory>
|
||||
<outputDirectory>/lib/x64</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
|
@ -1,13 +1,42 @@
|
|||
package org.bench4q.monitor;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bench4q.monitor.probe.windows.WindowsCpuProbe;
|
||||
|
||||
public class Main {
|
||||
static {
|
||||
System.load(System.getProperty("user.dir").replace("\\", "/")
|
||||
+ "/lib/Monitor.dll");
|
||||
System.load(System.getProperty("user.dir").replace("\\", "/")
|
||||
+ "/lib/Native.dll");
|
||||
String directory = Main.class.getProtectionDomain().getCodeSource()
|
||||
.getLocation().getFile().replace("\\", "/");
|
||||
File file = new File(directory);
|
||||
if (!file.isDirectory()) {
|
||||
directory = directory.substring(0, directory.lastIndexOf("/"));
|
||||
if (!directory.endsWith("/")) {
|
||||
directory += "/";
|
||||
}
|
||||
int arch = Integer.parseInt(System
|
||||
.getProperty("sun.arch.data.model"));
|
||||
if (arch == 64) {
|
||||
System.load(directory + "lib/x64/Monitor.dll");
|
||||
System.load(directory + "lib/x64/Native.dll");
|
||||
} else {
|
||||
System.load(directory + "lib/x86/Monitor.dll");
|
||||
System.load(directory + "lib/x86/Native.dll");
|
||||
}
|
||||
} else {
|
||||
// In IDE
|
||||
String userDir = System.getProperty("user.dir").replace("\\", "/");
|
||||
userDir += "/WindowsMonitor";
|
||||
int arch = Integer.parseInt(System
|
||||
.getProperty("sun.arch.data.model"));
|
||||
if (arch == 64) {
|
||||
System.load(userDir + "/x64/Release/Monitor.dll");
|
||||
System.load(userDir + "/x64/Release/Native.dll");
|
||||
} else {
|
||||
System.load(userDir + "/Release/Monitor.dll");
|
||||
System.load(userDir + "/Release/Native.dll");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
Loading…
Reference in New Issue