Could be a firewall blocking the port for you?
JamesCherrill
Posting Genius
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
AFAIK, you require "superuser" (also called as "root") privileges for binding to ports below 1024 and `sudo` does exactly that, run the program as a "superuser". From the sudo wikipedia entry:
By default, sudo will prompt for a user password but it may be configured to require the root password, and will require it only once every 15 minutes per pseudo terminal, or no password at all.
As you can see, it by default happily accepts the logged in user's password (just to confirm you really are you) before running commands as root. This can of course be configured differently to make sure sudo actually requires 'root' password but that's a different story.
Also, though admin users are almost like "superusers", there are a few areas wherein you actually require a superuser and you have stumbled upon one of them. The solution? When testing use a port which is above 1023, something like 8080. I don't do my development on a *nix box but there is a thread on SO which talks about the same stuff, maybe you can draw some inspiration from there but using a different port would be the easiest.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
If you want to distribute your application to users, just package your JAR along with shell scripts for specific platforms, just as it is done for applications like Tomcat etc.
If you are using such shell scripts, it would be pretty simple to put in the sudo in the script and all the user will see is a password prompt. Something like:
# runserver.sh
sudo java -jar httpserver.jar
This way, your users won't be aware of "sudo" in the script and would just have to type in the password, as intended.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734