blob: 40db2d89f47f311d4e994dab69080a972fafc635 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# Java example
## Build the JAR
From the top-level `libzt` directory:
```
./build.sh host-jar
```
Should result in something like:
```
dist
└── linux-x64-jar-release
└── pkg
└── libzt-1.8.10.jar
```
Copy the JAR to the working directory:
*NOTE: If you've built multiple variants of the JAR such as debug/release or mac/linux you will need to specify their exact path in the following command. If not, you can use the wildcard form:*
```
cp -f dist/*/pkg/*.jar examples/java/libzt.jar
```
Navigate to the `examples/java` directory and extract the `libzt.so|dylib|dll` dynamic library from the JAR into the working directory:
```
jar xf *.jar libzt.dylib libzt.so libzt.dll
```
## Build the example app
```
javac -cp *.jar Example.java
```
## Run the example app
```
java -Djava.library.path=. -cp ".:libzt.jar" Example server id_path 0123456789abcdef 9997
java -Djava.library.path=. -cp ".:libzt.jar" Example client id_path 0123456789abcdef ip.ip.ip.ip 9997
```
## Clean
```
rm -rf *.dylib *.so *.jar *.dll *.class
```
## Links
- Getting Started: [docs.zerotier.com/sockets](https://docs.zerotier.com/sockets/tutorial.html)
- Java API: [docs.zerotier.com/sockets-java](https://docs.zerotier.com/sockets-java/)
- Source [src/bindings/java](../../src/bindings/java)
|