This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

problems compiling with libgcj


I am new to this list, sorry if this is a too-newbie
querstion.  I am new to java (from the Perl side of
things) but my company is now doing more 'embedded'
devices, and Perl does not fit the bill.  Currently we
are using C on the device, and Java for the client,
and I would love to see Java being used on the device
too.  However, I need to find a SMALL footprint java
solution, and I thought that GCJ might be the
solution.

Here is the problem.  I have compiled (with javac) and
run the following code, taken from (Java by Example,
O'Reilly):

import java.io.*;
import java.net.*;

public class HttpMirror {
    public static void main(String args[]){
        try {
            int port = Integer.parseInt(args[0]);
            ServerSocket ss = new ServerSocket(port);
            for (;;){
                Socket client = ss.accept();
                BufferedReader in = new
BufferedReader(new
InputStreamReader(client.getInputStream()));
                PrintWriter out = new PrintWriter(new
OutputStreamWriter(client.getOutputStream()));

                out.println("HTTP/1.0 200");
                out.println("Content-Type:
text/plain");
                out.println();
                out.flush();

                String line;
                while ((line = in.readLine()) !=
null){
                    if (line.length() == 0) break;
                    out.println(line);
                }

                out.close();
                in.close();
                client.close();
                //ss.close();

            }
        }
        catch (Exception e) {
            System.err.println(e);
            System.err.println("Usage: java HttpMirror
<port>");
        }
    }
}


And when I run it with 'java HttpMirror' it runs fine,
but when I compile it with GCJ via:

      gcj --main=HttpMirror -o tester HttpMirror.class

I can hit the web server ONCE and then the second time
I get:

      java.io.IOException: Bad file descriptor
      Usage: java HttpMirror <port>

Again, it runs fine if compiled normally, but poops
out the SECOND time when compiled with GCJ (version
2.95.3, debian package on a debian 2.2.17 kernel box).
I don't understand why it is doing that.

Also, do I still have to have the libgcj on any box
that I run a compiled program?  I noticed that libgcj
is 1.5+ megs... which is too big for the embedded
device (and what kind of embedded device can handle
1.5 megs??).  Someone, please educate me on this. 

Thank you, VERY MUCH, for any help anyone can give.  I
appreciate your time and effort.

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]