- JDK 17+ — Download
- Maven 3.9+ — Download
- Visual Studio 2022 — Community/Professional/Enterprise/BuildTools
# 1. Build native DLL first (Windows)
compile.bat
# 2. Build JAR
mvn clean package -DskipTests| Command | Purpose |
|---|---|
compile.bat |
Build native DLL (Windows) |
mvn clean compile |
Compile Java only |
mvn clean package |
Build FatJAR with DLL embedded |
mvn test |
Run unit tests |
The compile.bat script:
- Auto-detects Visual Studio 2019/2022
- Auto-detects JAVA_HOME
- Uses
native\fastspider.deffor JNI exports - Outputs to
build\fastspider.dll
The Maven pom.xml will automatically pick up build\fastspider.dll and bundle it inside the JAR.
When using JNI, you MUST export your native functions in the native\fastspider.def file:
LIBRARY fastspider
EXPORTS
Java_fastspider_FastSpider_doSomethingNative
Important: Function names must match Java's expected format:
- Pattern:
Java_packagename_Classname_methodname
Without the .def file, JNI methods won't be exported and you'll get UnsatisfiedLinkError.
"Cannot find DLL" — Run compile.bat first
"UnsatisfiedLinkError" — Common causes:
- DLL built but not included in JAR (check
build/folder). - JNI exports missing — Verify
.deffile. - Wrong function name — Must match
Java_package_Class_methodexactly.
"Java version mismatch" — Ensure JDK 17+ is installed and JAVA_HOME is set.