yangyi 1 vecka sedan
incheckning
24603dfbf4
3 ändrade filer med 72 tillägg och 0 borttagningar
  1. 39 0
      .gitignore
  2. 17 0
      pom.xml
  3. 16 0
      src/main/java/space/anyi/jni/helloWorld/Main.java

+ 39 - 0
.gitignore

@@ -0,0 +1,39 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/**/**
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store

+ 17 - 0
pom.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>space.anyi</groupId>
+    <artifactId>JNI-learn</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+</project>

+ 16 - 0
src/main/java/space/anyi/jni/helloWorld/Main.java

@@ -0,0 +1,16 @@
+package space.anyi.jni.helloWorld;
+
+public class Main {
+    static {
+        //加载动态连接库
+    }
+    public static void main(String[] args) {
+        //调用本地方法
+        staticHelloWorld();
+        new Main().instanceHelloWorld();
+    }
+    //定义一个静态的本地方法
+    public static native void staticHelloWorld();
+    //定义一个普通的本地方法
+    public native void instanceHelloWorld();
+}