Testing JNI

This commit is contained in:
Andrea Cavalli 2017-12-10 01:09:27 +01:00
parent 6a99a0ea4c
commit 44ebaa787f
3 changed files with 89 additions and 83 deletions

View File

@ -5,6 +5,12 @@
<projects> <projects>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name> <name>org.eclipse.jdt.core.javabuilder</name>
<arguments> <arguments>
@ -15,9 +21,19 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

29
pom.xml
View File

@ -118,27 +118,10 @@
</plugins> </plugins>
</build> </build>
<!-- <!-- <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId>
<build> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration>
<plugins> <failOnError>false</failOnError> <source>1.8</source> <target>1.8</target>
<plugin> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>libs/</classpathPrefix>
<groupId>org.apache.maven.plugins</groupId> <mainClass>org.warp.picalculator.Main</mainClass> </manifest> </archive>
<artifactId>maven-jar-plugin</artifactId> </configuration> </plugin> </plugins> </build> -->
<version>2.4</version>
<configuration>
<failOnError>false</failOnError>
<source>1.8</source>
<target>1.8</target>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>libs/</classpathPrefix>
<mainClass>org.warp.picalculator.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
-->
</project> </project>

View File

@ -1,9 +1,16 @@
package org.warp.picalculator; package org.warp.picalculator;
import java.io.IOException;
import cz.adamh.utils.NativeUtils;
public class TestJNI { public class TestJNI {
static { static {
// picalculatornative.dll on Windows or libpicalculatornative.so on Linux try {
System.loadLibrary("picalculatornative"); NativeUtils.loadLibraryFromJar("/picalculatornative.dll");
} catch (IOException e) {
e.printStackTrace(); // This is probably not the best way to handle exception :-)
}
} }
private native void sayHello(); private native void sayHello();