Getting Started
What is jkit
jkit is a pure-JDK, zero-dependency general-purpose Java utility library, migrated from ZmlTools. It keeps the original utility capabilities while removing every third-party dependency (Gson, Fastjson, OkHttp, Guava, Apache Commons CSV, Jsoup, SLF4J, Logback, Lombok, etc.) — only the JDK standard library is used.
- Coordinates:
com.alianga:jkit - Compilation target: JDK 8+
- License: Apache License 2.0
Highlights:
- Zero third-party dependencies: the
<dependencies>section is empty, so adding jkit never leaks external libraries into your application — no version conflicts. - Dependency-free logging: a minimal facade
com.alianga.jkit.log.Logbuilt onjava.util.logging, with an SLF4J-style API ({}placeholders, trailingThrowableprints the stack trace). - Pure-JDK rewrites: CSV, JSON and every other utility are implemented without any external library.
Modules
This repository is a multi-module build rooted at jkit-parent. Pull in only what you need:
| Module | Coordinates | Description |
|---|---|---|
jkit-core | com.alianga:jkit | Runtime core (strings, dates, JSON, YAML, HTTP, configuration, …) |
jkit-sql | com.alianga:jkit-sql | Hand-written zero-dependency SQL parser matching the common entry points of Druid / JSqlParser |
jkit-sql-auto | com.alianga:jkit-sql-auto | Create / update tables from entities at startup (JDBC) |
jkit-sql-auto-spring-boot-2 | com.alianga:jkit-sql-auto-spring-boot-2 | Spring Boot 2 auto-config |
jkit-sql-auto-spring-boot-3 | com.alianga:jkit-sql-auto-spring-boot-3 | Spring Boot 3 auto-config (JDK 17+) |
jkit-notify | com.alianga:jkit-notify | Notifications: DingTalk / WeCom / Feishu / ServerChan / Bark / Webhook / SMTP |
jkit-notify-extra | com.alianga:jkit-notify-extra | Optional channels: Slack / Telegram / ntfy / SMS (Alibaba Cloud, Tencent Cloud, Yunpian, Huawei Cloud) |
jkit-curl-codegen | com.alianga:jkit-curl-codegen | Convert curl commands into OkHttp / fetch / requests and other source code |
Add the dependency
Core library:
<dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit</artifactId>
<version>2.0.1</version>
</dependency>Optional modules:
<dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit-sql</artifactId>
<version>2.0.1</version>
</dependency><dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit-sql-auto</artifactId>
<version>2.0.1</version>
</dependency><dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit-sql-auto-spring-boot-2</artifactId>
<version>2.0.1</version>
</dependency><dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit-sql-auto-spring-boot-3</artifactId>
<version>2.0.1</version>
</dependency><dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit-notify</artifactId>
<version>2.0.1</version>
</dependency><dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit-notify-extra</artifactId>
<version>2.0.1</version>
</dependency><dependency>
<groupId>com.alianga</groupId>
<artifactId>jkit-curl-codegen</artifactId>
<version>2.0.1</version>
</dependency>Auto schema (optional)
jkit-sql only generates SQL. To create / update tables at startup, pick one artifact. Full guide: Auto schema.
| Project | Artifact | Startup code |
|---|---|---|
| Plain Java | jkit-sql-auto | Call SqlAuto.run(...) once |
| Spring Boot 2 | jkit-sql-auto-spring-boot-2 | None. Set jkit.sql.auto.packages |
| Spring Boot 3 | jkit-sql-auto-spring-boot-3 | Same |
Minimal Spring Boot config:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/shop
username: shop
password: secret
jkit:
sql:
auto:
packages: com.example.entity
mode: updateYour first program
The basic utilities are static-method based — no setup objects required:
import com.alianga.jkit.csv.CSVUtils;
import com.alianga.jkit.DateUtils;
import com.alianga.jkit.common.idgenerate.SnowFlakeIdWorker;
import com.alianga.jkit.StringUtils;
import com.alianga.jkit.log.Log;
import java.io.File;
import java.util.Arrays;
import java.util.List;
public class QuickStart {
private static final Log log = Log.get(QuickStart.class);
public static void main(String[] args) throws Exception {
boolean blank = StringUtils.isBlank(" "); // true
String now = DateUtils.getNowDateTime(); // yyyy-MM-dd HH:mm:ss
long id = SnowFlakeIdWorker.INSTANCE.nextId(); // snowflake ID
List<List<String>> rows = Arrays.asList(
Arrays.asList("Tom", "18"),
Arrays.asList("Lucy", "20"));
CSVUtils.write(new File("target/users.csv"), rows, "name", "age");
List<List<String>> back = CSVUtils.read(new File("target/users.csv"));
log.info("id={}, now={}", id, now);
}
}What to read next
| Topic | Docs |
|---|---|
| Strings, collections, crypto, reflection, thread pools | Misc Utilities |
| Files, resources, properties, file monitoring | IO & Resources |
| Serialization, POJO binding, JSONNode, JSONPath, Schema | JSON |
| YAML parsing, node tree, anchors, multi-documents | YAML |
| Spring Boot-style externalized configuration | Configuration |
| GET/POST, upload & download, SSE, load balancing | HTTP Client |
| Multi-dialect SQL parsing, formatting, pagination rewrite | SQL Parsing |
| DingTalk / WeCom / Feishu / email notifications | Notification |
Migrating from ZmlTools
The Maven coordinates moved from top.wuyongshi:ZmlTools to com.alianga:jkit, and the package prefix from top.wys.utils.* to com.alianga.jkit.*:
- Edit your POM (recommended): switch the
groupId/artifactIdtocom.alianga:jkit:2.0.1and rewritetop.wys.utils.*imports tocom.alianga.jkit.*. - Maven relocation: after publishing
relocated/zmltools/pom.xml, builds depending on the old coordinates are redirected automatically (imports still need manual rewriting).
Limitations & compatibility
- Source and bytecode target JDK 8; JDK 9+ works, but the JSON Unsafe fast path is subject to runtime module permissions — call
JSONVmOptions.forceRequiredMemoryAlignment()if needed. - The published jar carries no runtime third-party dependencies; JUnit is test-scoped only.
sun.misc.Unsafeis used purely for performance; application code should not rely on the internaljson.internalpackages.- Crypto helpers, file writers and network helpers do not manage keys, path safety, timeouts or certificate policies for you.
Build from source
# Use a JDK 8 provided via environment variables (JAVA8_HOME or JDK8_HOME)
export JAVA_HOME="${JAVA8_HOME:-${JDK8_HOME}}"
export PATH="$JAVA_HOME/bin:$PATH"
mvn package # compile & package (dependency-free, fast)
mvn test # run unit tests (JUnit 4, test scope)
mvn install # install to the local repository