package clientP2P; import java.io.File; import clientP2P.ClientManagementUDP; public class ClientP2P { private String host; private int port; private String directory; public ClientP2P() { host = "localhost"; port = 40000; String d; /* Follow XDG Base Directory Specification * https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html */ if (System.getProperty("os.name").equals("Linux")) { d = System.getenv().get("XDG_DATA_HOME"); if (d == null || d.equals("")) { d = System.getenv().get("HOME"); if (d != null && (!d.equals(""))) { d += "/.local/share"; } else { d += "."; } } } else { d = "."; } d += "P2P_JAVA_PROJECT_CLIENT/"; // create directory if not already exists new File(d).mkdirs(); } public static void main(String [] args) { ClientP2P c = new ClientP2P(); ClientManagementUDP cm = new ClientManagementUDP(c.directory, c.host, c.port); Thread t = new Thread(cm); t.setName("client P2P-JAVA-PROJECT"); t.start(); } }