What libraries exist for programming Tor Hidden Services in Java?

I am looking for a Java implementation of the Tor Rendezvous Specification that allow you to implement a service using an existing implementation of the protocol. This library would let you implement a call back and handle the Tor protocol for you the same way you can extends the class Servlet and have the servlet container handling the HTTP protocol for you.

If possible, please provide links for the libraries home page, sample code and tutorials.

  • let us continue this discussion in chat
    – user5
    Commented Nov 1, 2013 at 1:58
  • Reopened the question and cleaned up discussion.
    – user5
    Commented Nov 1, 2013 at 2:31

3 Answers 3


Hidden Services are simply servers. Tor doesn't care, or know, about what exactly is serving the service - it could be a website, or an email server, or almost anything else.

If you can write a Server in Java (or use an existing one such as Jetty for a HTTP Server), then you can use it to serve a Hidden Service. You would configure it so that it will accept TCP connections only from localhost/ on a port of your choosing. Further help with either configuring an existing Java Server, or writing your own is probably beyond the scope of this site.

You would then edit your Tor configuration file to tell it to publish a Hidden Service, where your Tor Client would forward the requests to the port you specified in your Server. For further details see the Tor Documentation, or other questions such as this one. If you encounter an issue with this part of the setup, that problem may be on topic here, so further questions could be asked.

  • Or any other kind of TCP server for that matter. No need to serve HTTP.
    – user5
    Commented Oct 31, 2013 at 1:31
  • Good point. edited. Commented Oct 31, 2013 at 8:28
  • When you run a program like torchat do not need to edit the configuration of tor, neither to have tor install. There are program that publish a hidden service directly. This is doable in Java. Is there a library that does it. Commented Oct 31, 2013 at 22:00
  • 1
    Torchat bundles its own Tor client, which is why you do not need to edit any tor.conf file - it uses the bundled Tor which is already configured correctly, and it communicates with Tor as my original answer does. So am I right in thinking that the question is essentially "Are there any Java implementations of Tor?". If so, I can edit my answer to fit that. If not, then could you clarify further? As a programmer I'm not sure how you'd do such a thing without a full Tor Client somewhere in the path, which uses the solution outlined in my existing answer. Commented Nov 1, 2013 at 18:32
  • 1
    I am looking for a jar file that implements a tor client, that can be used by any project. This is not same thing as a process that connect to tor (Which is a Java implementation, but not a library). Commented Nov 9, 2013 at 19:26

silvertunnel-ng should do what you want. It's a Java library for easily accessing the Tor network.

Checkout the Unittests for how to access/provide a hidden service.


T0rlib4j is the best choice by far because it is fullly funtional and is up to dated . With it you can use a java app Tor's control protocol to communicate against the Tor process an connect to a hidden service via SOCKS4a/5 proxy. The documentation is fully detailed and worths to take a look. In addition, it has a working Samples Client - Server model in order to start connecting to Tor

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .