From d2db92858a1a227a9dbad7adb5145fdaec104312 Mon Sep 17 00:00:00 2001 From: Changhua Date: Fri, 24 Mar 2023 00:33:04 +0800 Subject: [PATCH] Add readme --- java/README.MD | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 java/README.MD diff --git a/java/README.MD b/java/README.MD new file mode 100644 index 0000000..91eab47 --- /dev/null +++ b/java/README.MD @@ -0,0 +1,63 @@ +# WeChatFerry Java 客户端 +⚠️ **只支持 Windows** ⚠️ + +## 快速开始 +* 下载 [最新发布的版本](https://github.com/lich0821/WeChatFerry/releases/latest),解压,找到 java 客户端。 + +* 使用惯用 IDE,打开工程,编译,运行。 + +## 从头开始 +【添加 `wcferry` 依赖】是必须要执行的,工程里不带这几个文件;如果开发新功能,一般需要修改 `wcf.proto`,从而需要重新生成 PB 文件;其他的,一般不需要关注。 + +### 添加 `nng` 依赖 +* 新建一个 `libs` 目录 +* 参考 [nng-java](https://github.com/voutilad/nng-java),编译 jar 包(`nng-java-1.4.0-SNAPSHOT.jar`) +* 添加依赖 `nng-java-1.4.0-SNAPSHOT.jar` +```groovy +implementation 'net.java.dev.jna:jna:5.6.0' +implementation fileTree(dir: 'libs', include: ['*.jar']) +``` + +#### 编译 / 安装 `mbedtls` +* 下载 [Mbed TLS](https://github.com/Mbed-TLS/mbedtls) 代码并解压 +* 新建 `build` 目录,生成 VS 工程 +```sh +cd build +cmake .. +``` + +* 以管理员身份运行 VS2019,打开 `mbed TLS.sln`,选择 `Release` `x64`,编译即可 +* [参考](https://github.com/Mbed-TLS/mbedtls) + +#### 编译 / 安装 `nng` +* 下载 [nng](https://github.com/nanomsg/nng) 代码并解压 +* 新建 `build` 目录,生成 VS 工程 +```sh +cmake -DBUILD_SHARED_LIBS=ON -DNNG_ENABLE_TLS=ON -DMBEDTLS_ROOT_DIR="C:\Program Files (x86)\mbed TLS" .. +``` + +* 打开 `nng.sln`,选择 `Release` `x64`,编译即可 +* [参考](https://github.com/nanomsg/nng/issues/953) + +### 添加 PB 依赖 +```groovy +implementation 'com.google.protobuf:protobuf-java:3.22.2' // 版本需要和 protoc 一致 +``` + +#### 重新生成 PB 文件 +参考 [Protocol Buffer Basics: Java](https://protobuf.dev/getting-started/javatutorial/#problem-domain)。 +* 下载 `protoc` 工具(注意,需要与 `com.google.protobuf:protobuf-java` 一致): +这里下载 [protoc-22.2](https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-win64.zip),解压,并将所在路径加入环境变量(以便随处可用)。 + +* 编译 PB 文件 +```sh +cd C:/Projs/WeChatFerry/java/wcferry/src/main/java +protoc.exe --java_out=. --proto_path=C:\Projs\WeChatFerry\rpc\proto wcf.proto +``` + +### 添加 `wcferry` 依赖 +将 `wcf.exe` 、 `spy.dll` 、 `spy_debug.dll` 添加到 `C:\Projs\WeChatFerry\java\wcferry\src\main\resources\win32-x86-64`。 + +### 其他问题 +### 乱码 +参考 [这篇文章](https://www.quanxiaoha.com/idea/idea-chinese-garbled-code.html)。