[ale] Java socket problem

Bill Binko bill.binko at trcinc.com
Thu Aug 1 10:00:02 EDT 1996


David Cleveland Haynes wrote:
> 
> I have written a server in Java that is supposed to listen for connections
> on a specified port. Pretty standard. Here is the error message I get when
> I run the compiled ( .class ) code :
> 
> java.lang.NullPointerException
>         at java.lang.Runtime.loadLibrary(Runtime.java)
>         at java.lang.System.loadLibrary(System.java)
>         at java.net.PlainSocketImpl.<clinit>(PlainSocketImpl.java:43)
>         at java.net.ServerSocket.<init>(ServerSocket.java:48)
>         at java.net.ServerSocket.<init>(ServerSocket.java:69)
>         at java.net.ServerSocket.<init>(ServerSocket.java:58)
>         at Server.<init>(Server.java:19)
>         at Server.main(Server.java:48)
> java.lang.UnsatisfiedLinkError: socketCreate
>         at java.net.PlainSocketImpl.create(PlainSocketImpl.java:53)
>         at java.net.ServerSocket.<init>(ServerSocket.java:76)
>         at java.net.ServerSocket.<init>(ServerSocket.java:58)
>         at Server.<init>(Server.java:19)
>         at Server.main(Server.java:48)
> 

Well.. First, you have a typo (that I think is probably not in your
code)  in that you're missing a "}" at the end of the try.  Also, in
newer versions of the JDK, you must put the catch block in "{}"'s.  This
isn't true in 1.0.1, so you're alright, but if you want it portable, you
ought to get familiar with it.

> Here is the code from Server.java, starting at line 19:
> 
>       try { listen_socket = new ServerSocket( port );
>       catch( IOException e ) fail( e, "Exception creating server socket" );
>       System.out.println( "Server: listening on port " + port );
> 

It looks like the problem is that Java can't find the libnet.so file. 
Make sure that that file is either in one of the places that ldconfig
looks (i.e. /usr/local/lib/) or that your LD_LIBRARY_PATH points to the
directory it's located in. (Usually something like
/usr/local/java/lib/i586/).

Hope this helps.

Bill


> I have set the port to 9999.
> 
> Any ideas would be much appreciated.
> 
>                                         Dave






More information about the Ale mailing list