diff --git a/examples/java/ZeroTierHelloWorld/.classpath b/examples/java/ZeroTierHelloWorld/.classpath
index ac1a9db..3e0d493 100644
--- a/examples/java/ZeroTierHelloWorld/.classpath
+++ b/examples/java/ZeroTierHelloWorld/.classpath
@@ -3,7 +3,12 @@
-
+
+
+
+
+
+
diff --git a/examples/java/ZeroTierHelloWorld/bin/.gitignore b/examples/java/ZeroTierHelloWorld/bin/.gitignore
deleted file mode 100644
index 4d39377..0000000
--- a/examples/java/ZeroTierHelloWorld/bin/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/MyClass$1.class
-/zerotier/
-/MyClass.class
diff --git a/examples/java/ZeroTierHelloWorld/bin/MyClass.class b/examples/java/ZeroTierHelloWorld/bin/MyClass.class
deleted file mode 100644
index fff559f..0000000
Binary files a/examples/java/ZeroTierHelloWorld/bin/MyClass.class and /dev/null differ
diff --git a/examples/java/ZeroTierHelloWorld/src/MyClass.java b/examples/java/ZeroTierHelloWorld/src/MyClass.java
index d71377d..71c19aa 100644
--- a/examples/java/ZeroTierHelloWorld/src/MyClass.java
+++ b/examples/java/ZeroTierHelloWorld/src/MyClass.java
@@ -1,4 +1,30 @@
-// Hello World example for the ZeroTierSDK
+/*
+ * ZeroTier SDK - Network Virtualization Everywhere
+ * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * --
+ *
+ * You can be released from the requirements of the license by purchasing
+ * a commercial license. Buying such a license is mandatory as soon as you
+ * develop commercial closed-source software that incorporates or links
+ * directly against ZeroTier software without disclosing the source code
+ * of your own application.
+ */
+
+// Simple Java example for libzt using JNI
import zerotier.*;
@@ -8,33 +34,26 @@ public class MyClass {
public native void startOneService();
static {
- System.loadLibrary("zt");
+ System.load("/Users/joseph/op/zt/libzt/build/darwin/libzt.so");
}
public static void main(String[] args) {
- System.out.println("Welcome to the Machine");
-
final ZeroTier z = new ZeroTier();
-
+
new Thread(new Runnable() {
public void run() {
- // Calls to JNI code
- z.start("/Users/Joseph/op/code/zerotier/ZeroTierSDK/zt1");
+ System.out.println("starting libzt");
+ z.startjoin("/Users/joseph/op/zt/libzt/ztjni", "1212121212121212");
+ // start(path) will not block
+ // startjoin(path, nwid) will block
}
}).start();
- //while(!z.running()) { }
-
while(true)
{
- try {
- System.out.println("Welcome to the Machine");
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ try { Thread.sleep(3000); }
+ catch (InterruptedException e) { e.printStackTrace(); }
}
}
}
\ No newline at end of file
diff --git a/examples/java/ZeroTierHelloWorld/src/zerotier/Address.java b/examples/java/ZeroTierHelloWorld/src/zerotier/Address.java
index 2400c91..530ee27 100644
--- a/examples/java/ZeroTierHelloWorld/src/zerotier/Address.java
+++ b/examples/java/ZeroTierHelloWorld/src/zerotier/Address.java
@@ -1,3 +1,29 @@
+/*
+ * ZeroTier SDK - Network Virtualization Everywhere
+ * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * --
+ *
+ * You can be released from the requirements of the license by purchasing
+ * a commercial license. Buying such a license is mandatory as soon as you
+ * develop commercial closed-source software that incorporates or links
+ * directly against ZeroTier software without disclosing the source code
+ * of your own application.
+ */
+
package zerotier;
import java.math.BigInteger;
diff --git a/examples/java/ZeroTierHelloWorld/src/zerotier/ZeroTier.java b/examples/java/ZeroTierHelloWorld/src/zerotier/ZeroTier.java
index b312f25..db39e48 100644
--- a/examples/java/ZeroTierHelloWorld/src/zerotier/ZeroTier.java
+++ b/examples/java/ZeroTierHelloWorld/src/zerotier/ZeroTier.java
@@ -1,6 +1,6 @@
/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
+ * ZeroTier SDK - Network Virtualization Everywhere
+ * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,12 +17,11 @@
*
* --
*
- * ZeroTier may be used and distributed under the terms of the GPLv3, which
- * are available at: http://www.gnu.org/licenses/gpl-3.0.html
- *
- * If you would like to embed ZeroTier into a commercial application or
- * redistribute it in a modified binary form, please contact ZeroTier Networks
- * LLC. Start here: http://www.zerotier.com/
+ * You can be released from the requirements of the license by purchasing
+ * a commercial license. Buying such a license is mandatory as soon as you
+ * develop commercial closed-source software that incorporates or links
+ * directly against ZeroTier software without disclosing the source code
+ * of your own application.
*/
package zerotier;
@@ -35,9 +34,8 @@ import java.util.zip.ZipError;
public class ZeroTier {
- public static String Version()
- {
- return "1.2.2";
+ public static String Version() {
+ return "1.1.5";
}
// Socket families
@@ -60,14 +58,15 @@ public class ZeroTier {
public static int F_SETFL = 4;
// Loads JNI code
- static { System.loadLibrary("zt"); }
+ //static { System.loadLibrary("zt"); }
// ZeroTier service controls
public native void ztjni_start(String homeDir);
- public void start(String homeDir) {
- ztjni_start(homeDir);
- }
+ public void start(String homeDir) { ztjni_start(homeDir); }
+ public native void ztjni_startjoin(String homeDir, String nwid);
+ public void startjoin(String homeDir, String nwid) { ztjni_startjoin(homeDir, nwid); }
+
public native void ztjni_join(String nwid);
public void join(String nwid) {
ztjni_join(nwid);
@@ -96,20 +95,13 @@ public class ZeroTier {
}
public native boolean ztjni_running();
- public boolean running() {
- return ztjni_running();
- }
+ public boolean running() { return ztjni_running(); }
public native int ztjni_socket(int family, int type, int protocol);
- public int socket(int family, int type, int protocol) {
- return ztjni_socket(family, type, protocol);
- }
+ public int socket(int family, int type, int protocol) { return ztjni_socket(family, type, protocol); }
public native int ztjni_connect(int fd, String addr, int port);
-
- public int connect(int sock, Address zaddr, String nwid) {
- return connect(sock, zaddr.Address(), zaddr.Port(), nwid);
- }
+ public int connect(int sock, Address zaddr, String nwid) { return connect(sock, zaddr.Address(), zaddr.Port(), nwid); }
public int connect(int sock, String addr, int port, String nwid)
{
@@ -131,10 +123,8 @@ public class ZeroTier {
}
public native int ztjni_bind(int fd, String addr, int port);
-
- public int bind(int sock, Address zaddr, String nwid) {
- return bind(sock, zaddr.Address(), zaddr.Port(), nwid);
- }
+ public int bind(int sock, Address zaddr, String nwid) { return bind(sock, zaddr.Address(), zaddr.Port(), nwid); }
+
public int bind(int sock, String addr, int port, String nwid) {
int err = -1;
ArrayList addresses;