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>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@ -15,9 +21,19 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</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>
</projectDescription>

145
pom.xml
View File

@ -1,12 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.warp.picalculator</groupId>
<artifactId>warppi-calculator</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>WarpPI Calculator</name>
<url>http://warp.ovh</url>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.warp.picalculator</groupId>
<artifactId>warppi-calculator</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>WarpPI Calculator</name>
<url>http://warp.ovh</url>
<repositories>
<repository>
<id>oss-snapshots-repo</id>
@ -18,49 +18,49 @@
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>7.2.0</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependencies>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.15</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ar.com.hjg</groupId>
<artifactId>pngj</artifactId>
<version>2.1.0</version>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>7.2.0</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>ar.com.hjg</groupId>
<artifactId>pngj</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<finalName>WarpPICalculator</finalName>
<plugins>
@ -98,47 +98,30 @@
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>org.warp.picalculator.Main</mainClass>
</manifest>
<manifest>
<mainClass>org.warp.picalculator.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<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>
-->
<!-- <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <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>

View File

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