views:

467

answers:

4

I'm running in to an error when I try to run my server application from Eclipse. The error is java.net.BindException: Permission denied. I think this is because I am using port 443 to set up an SSL connection. I can get around this problem if I run my code on the command line using java and sudo. Is there a way to set up Eclipse so that when I hit the run button, my application is executed with sudo?

A: 

If you use External tools (Run menu/External tools or an icon next to the Run/Debug icons on the toolbar), you can use any scripts or whatever you like. The scripts may give you elevated rights, or whatever.

On the other hand, this way debugging the application can become very hard, as neither the Run nor Debug commands get associated with this External tool configuration. Maybe it is possible to connect the Eclipse debugger of the application, but I don't know, how that is possible.

Zoltán Ujhelyi
+1  A: 

Assuming you are on Linux (*nix), How about starting your eclipse session via a sudo command?

Such as

sudo ~/eclipse/eclipse

Now whatever you do from eclipse will have the sudo context?

ring bearer
-1 - This is undesirable ... and dangerous. Any files that you write using eclipse will be owned by root. Worse still, since eclipse is running root, it has permission to read, write or delete any file or directory. Modify or delete the wrong file and you could enter a world of pain.
Stephen C
Ouch that hurts. I thought I had just answered for exactly what he was looking for. I wouln't sweat all the ifs-and-buts you mentioned when I am on my development box.
ring bearer
A: 

As mentioned in this thread:

In order to open a port below 1024 on Unix/Linux systems you need to be "root".

I also used the argument -Dorg.eclipse.equinox.http.jetty.port=8080 to change the listen port, but this seems to be ignored (according to the stacktrace)

Please use "-Dorg.osgi.service.http.port=8080".


As mentioned in HTTP Service:

  • org.osgi.service.http.port - specifies the port number to use for the http serving. The default value for this property is 80 (which requires root permission), as per the OSGi specification.

  • org.osgi.service.http.port.secure - specifies the port number to use for secure http serving. The default value for this property is 443 (which requires root permission), as per the OSGi specification.

Maybe if you try to modify that last property to a value above 1024 it could work without requiring any special privilege.

VonC
A: 

Another option would be to use iptables or ipfilter to forward port 80 to a port above 1024.

(Can someone contribute a link to a practical and easy-to-understand explanation ?)

Stephen C