Feat: add inject-via-java-api example with JNI refactor

- Rename JNI class from InjectorNative to Injector in libinject.c

- Add JNI header for cn.xiaozhou233.juiceagent.injector.Injector

- Add inject-via-java-api example with HowToUse.txt and 如何使用.txt
This commit is contained in:
xiaozhou233 committed 2026-08-15 21:51:48 +08:00
1 parent 32e9199d4a
commit a1b0eb8b84
14 files changed
+391 -8

No files matched your search

@@ -0,0 +1,28 @@
@echo off
setlocal
set "SRC=target.java"
set "OUT=out"
set "JAR=..\target.jar"
if exist "%OUT%" rmdir /s /q "%OUT%"
if exist "%JAR%" del /q "%JAR%"
mkdir "%OUT%"
javac -encoding UTF-8 --release 8 -d "%OUT%" "%SRC%"
if errorlevel 1 goto :error
jar --create --file "%JAR%" --main-class target -C "%OUT%" .
if errorlevel 1 goto :error
rmdir /s /q "%OUT%"
echo Build succeeded: target.jar
goto :end
:error
echo Build failed.
exit /b 1
:end
endlocal
@@ -0,0 +1,15 @@
import java.lang.management.ManagementFactory;
public class target {
public static void main(String[] args) {
String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
try {
while (true) {
System.out.println("[Target] I am the target JVM (PID: " + pid + ")");
Thread.sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}