title: Java Tor Lib : How to setup Orchid Tor Lib with Java?
body: <p>I am trying to implement Orchid Tor lib with Java code; unfortunately and because the lack of documentation I am not able to make it work, this is what I did:</p>
  
  <p>....................</p>
  
  <pre><code>private final static String DEFAULT_SOCKS_PORT = "9050";
  
   TorClient torClient = new TorClient();
  
   torClient.addInitializationListener(new TorInitializationListener() {
  
      @Override
      public void initializationProgress(String string, int i) {
         System.out.println("&gt;&gt;&gt; [ "+ i + "% ]: "+ string);
      // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
      }
  
      @Override
      public void initializationCompleted() {
          try {
  
              System.out.println("Tor is ready to go!");
  
              setSystemProperties("127.0.0.1","8118");
  
              System.out.println("is online "+isOnline()); //isOnilne is just function return true if connected by pinging google.com
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  });
  
  torClient.enableDashboard(8118);
  
  torClient.enableSocksListener(9050);
  
  torClient.start();
  
  private static void setSystemProperties(String host, String port)
  {
  
      System.setProperty("proxyHost", host);
      System.setProperty("proxyPort", port);
  
      System.setProperty("http.proxyHost", host);
      System.setProperty("http.proxyPort", port);
  
      System.setProperty("https.proxyHost", host);
      System.setProperty("https.proxyPort", port);
  
  
      System.setProperty("socks.proxyHost", host);
      System.setProperty("socks.proxyPort", DEFAULT_SOCKS_PORT);
  
      System.setProperty("socksProxyHost", host);
      System.setProperty("socksProxyPort", DEFAULT_SOCKS_PORT);
  
  }
  </code></pre>