Java Windows: Could not get IPs correctly and Could not send data via sockets.
MegumiKasuga opened this issue · comments
I compiled my jar with ./build.sh host-jar
and
the lib with . .\build.ps1; Build-Library -BuildType "Release" -Arch "x64" -LangBinding "java"
using cmake3
, gcc 11.4.0
and OpenJDK 17.0.8 (ms build)
To fix compile errors,
I have replaced Visual Studio 16 2019
with Visual Studio 17 2022
in build.ps1
and build.sh
.
replaced s_addr
with S_addr
in src/bindings/java/JavaSockets.cxx
(line 393 and line 431)
add return 0;
for
Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1get
(line 594)Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1get_1all
(line 614)Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1compute_16plane
(line 626)Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1compute_1rfc4193
(line 636)
(They are all empty method, but the compiler said that they must have something to return
, so I make them all return 0)
add include_directories(${ZTO_SRC_DIR}/ext/)
, and changed the JNI path to my own path (in CMakeFiles.txt)
Then, I moved my lib and jar into my IDE workspace, and write an example program just like example.java
![2](https://private-user-images.githubusercontent.com/98652627/331814221-9b464ed5-be77-4b30-9116-bca8cde65867.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA2NzUyMzAsIm5iZiI6MTcyMDY3NDkzMCwicGF0aCI6Ii85ODY1MjYyNy8zMzE4MTQyMjEtOWI0NjRlZDUtYmU3Ny00YjMwLTkxMTYtYmNhOGNkZTY1ODY3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzExVDA1MTUzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk4MzliNGIxNWYzZGZhNjRkOTk0ZjE2ZWQ3MjYyOTEzM2YzMDc4MWRkMjczZTJhN2Q3YjRhMjQ0ZjZhM2Y2YjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.k1sa1NPlxqCfCDvAn3nfnYQPmIVGLGgVpX-ReLRebFQ)
The program now has some Unexpected bugs:
- Could not get IPs correctly (Included IPv4 and IPv6), The native method returns
- Could not send and recive datas through sockets. The program got stuck in connecting phase.
But it acts normal in:
- joining networks.
- get MAC address.
- get NodeID.
I have test my program using libzt.dll of 1.8.10
and 1.8.4
, and they both have the problems mentioned above.
See solutions here: #267