#31 localhost windows 8


Not sure if it is a bug, but the GUI allows use of localhost to pick up the local IP address. Is this available in command line? It would be useful to autoset UPNP when the IP is via a router DHCP.

Andy Barker


  • Anonymous - 2014-02-10

    Sorry - Windows 7 (if it makes any difference!)

  • Christoph

    Christoph - 2014-02-10

    Hi Andy, thanks for using PortMapper.

    Option -r should do what you want:

    java -jar PortMapper-1.9.6.jar -r <port protocol [...]>

    e.g. -r 1234 TCP 4321 UDP

  • Anonymous - 2014-10-31

    Hi Christoph, is there a way to setup the -r flag so it behaves more like -a? It would be nice to be able to specify a different external port from the internal port.

    -a 80 8080 TCP
    -r 80 8080 TCP

  • Christoph

    Christoph - 2014-11-08

    Hi Anonymous,

    thank you for your feature request. I will check if this is possible!

    Kind regards,

  • Anonymous - 2014-11-13

    Hey Christoph, thanks for the reply. I made a quick modification to the -a flag to get the code to do what I needed it to. Basically if "-a" only has 3 parameters instead of 4 it assumes that the person wants to use the local host address. Here is a patch and a diff if you want to bring the code into the mainline. It shouldn't be too hard to adapt if you'd rather have the logic execute using the "-r" flag.

    patch: http://pastebin.com/mBacirBJ
    diff: https://github.com/xtraeme-xt/portmapper/commit/cf1c35319288213dda154bfe84013008acb69857

    Also, I am curious how did you get the code to compile in JDK 1.6? The original PortMapper-1.9.5.jar shows in the manifest that you used 1.6.0_29-b11-402-11D50b. When I compile the project with jdk1.6.0_45 javac complains about the diamond operators (e.g. new ArrayList<>()). I'd love to get code running again on Snow Leopard (PortMapper-1.9.5 worked great on Mac 10.6), but due to the compiler errors I am at a bit of an impasse.

    Any advice that you have would be very much appreciated.

    Basically what I've done is I loaded the project in to netbeans, imported the old libs from the sourceforge SVN repo, and used one-jar-boot to package everything into a single jar. I modified build.xml to try to simplify the build process (http://www.oracle.com/technetwork/java/javamail/single-jar-141905.html), but because it kept excluding log4j.properties and some of the other resources (despite the resources being included in the libraries) I gave up and resorted to doing it with one-jar. I only noticed earlier this evening that you moved to using grail on the github branch. So I'll look through that next to see if I can figure out how to proceed.

    Anyhow, thanks for your help and all your great work Christoph.

    Best regards.

  • Anonymous - 2014-11-13

    I wanted to quick add I managed to get the build working on Snow Leopard. I just grabbed the 1.9.4 SVN tag, added the modifications, and rebuilt. Everything works beautifully. Thanks again for the great project christoph.

  • Christoph

    Christoph - 2014-11-25

    Hi Anonymous,

    sorry for the late reply and thank you very much for your patch! I will apply it when I find the time.

    Regarding the Java version: I installed JDK 1.8 under Yosemite, you need at least 1.7 to compile the current code. If you want to execute the program with Java 1.6, you will need to add the following lines to build.gradle:


    I did not test this, but it should work.

    Best regards,

  • Christoph

    Christoph - 2015-04-11

    I refactored the command line interface. Now it allows you to always specify internal and external ports. Just omit the -ip flag to use localhost.

  • Christoph

    Christoph - 2015-04-11
    • status: open --> closed
    • assigned_to: Christoph


Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks