java.net.SocketException: Permission denied: listen failed

Hello,

I'm experiencing the weirdest problem ever -

it seems that I"m unable to open a java server socket on my machine.

Here is a sample code that demonstrates my problem:

-

import java.io.IOException;

import java.net.*;

public class SocketTest

{

/**

* @param args

*/

public static void main(String[] args)

{

ServerSocket myService;

try

{

myService = new ServerSocket(8080);

System.out.println("successfully opened a socket");

}

catch (IOException e)

{

e.printStackTrace();

System.out.println(e);

}

}

}

Here is the exception that I get:

--

java.net.SocketException: Permission denied: listen failed

at java.net.PlainSocketImpl.socketListen(Native Method)

at java.net.PlainSocketImpl.listen(Unknown Source)

at java.net.ServerSocket.bind(Unknown Source)

at java.net.ServerSocket.<init>(Unknown Source)

at java.net.ServerSocket.<init>(Unknown Source)

at SocketTest.main(SocketTest.java:18)

java.net.SocketException: Permission denied: listen failed

I'm trying to run this app on winxp machine, jre 1.5.0_11.

This problem also happens not ony while running this application, but while trying to start other java applications like tomcat.

If I try to connect to already used port, I get a different exception, so I know this port is free.

I've already tried to reinstall the jre, as well as rebooting my machine.

Also I have no firewall or antivirus running.

Any help is highly appreciated!

Thanks,

Vitaliy

[1695 byte] By [vitaliy.fa] at [2007-11-27 9:37:42]
# 1
No firewall? Check Windows default firewall
SidGatea at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...
# 2
Rechecked.It is Off, Its service is stoped.Thanks,Vitaliy
vitaliy.fa at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...
# 3
Nothing to do with the firewall.It is a Java security issue. See java.net.SocketPermission. You need to grant yourself this permission in the applicable .policy file.
ejpa at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...
# 4
How can I do it?Thanks,Vitaliy
vitaliy.fa at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...
# 5
http://java.sun.com/j2se/1.5.0/docs/guide/security/permissions.html http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/policytool.html
ejpa at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...
# 6
I have no special security policies.I've reinstalled jre, so I have the default permissions that come with the jre.Thanks,Vitaliy
vitaliy.fa at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...
# 7
I'm sorry I was dead wrong. It is an O/S access control or firewall problem, nothing to do with Java permissions.
ejpa at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...
# 8

Nop. It's the strangest eclipse & jre problem.

Here's why:

If I run it outside of eclipse at command line it works fine!!

Moreover - if I run it inside eclipse with a different jre it also works!

Here's a summary of what I tried:

Eclipse + jre 1.4.2_13 - THROWS the exception.

Eclipse + jre 1.5 - OK

cmd + jre 1.4.2_13 - OK

cmd + jre 1.5 - OK

The problem is that I need to run it on jre 1.4..

I've tried to reinstall eclipse, jres - no use!

Any ideas?

Thanks allot for any help,

Vitaliy

vitaliy.fa at 2007-7-12 23:09:28 > top of Java-index,Java Essentials,Java Programming...