Java is Free! Thank You Sun.

Posted in Free Software, Java at 5:05 pm by Pirate Praveen

Java is Free!

I think Sun has well, with this contribution have contributed more than any other company to the free
software community in the form of software. It shows leadership. Its an example I hope others will follow.
— Dr. Richard Stallman, Founder of GNU Project and Free Software Foundation

This is indeed great victory for Free Software. A great part of this incredible progress is due to the great work of so many Free Java hackers. The runtime, compilers and GlassFish Aplication server will be available under GPLv2 and the libraries under GPLv2+classpath exception.

–j4v4m4n (that is my IRC nick and what my friends call me, so it is even a personal victory for me!)


Java programming with gcj

Posted in Java at 3:00 pm by Pirate Praveen

How to compile and run java programs using GCJ ?

$ gcj -C hello.java

is similar to javac hello.java and it creates a class file hello.class

$ gij hello

is similar to java as it executes bytecode in hello.class

what gcj offers that is not available with reguar jdk is support for creating binaries

$ gcj hello.java --main=hello

or if you already have the class file

$ gcj hello.class --main=hello

will create a binary file a.out and you can execute it using

$ ./a.out

it is similar to compiling with gcc and you can specify a different output file with -o option

$ gcj hello.java --main=hello -o hello
$ ./hello

More information on gcj see http://gcc.gnu.org/java/


Java Webserver inspired from Thejesh

Posted in Free Software, Java at 3:15 pm by Pirate Praveen

Here is Thejesh’s page

The requirement is (from thejesh’s portal techmag.biz)

Let us write a simple web server in Java.The purpose is learning. A webserver listens at a given port and gives back the file asked (request). Here only http requests are considered.
Let us keep it simple and serve only HTML pages and not GIF’s and JPEG’s.

Points to consider:
(1) The server will to on a port. By default all the web servers listen to port 80. We are allowed to use other ports unless it is used by other process.
(2) Every webserver will have a root folder. Only the files under this root folder are accessible by the server.
(3) We will serve only .htm or .html files
(4) When we get the request. the first line of the request will contain the word “GET” followed by the file name.
(5) The server should be multithreaded to handle multiple requests.
(6) The first line of the response will be “HTTP/1.0 200 OK”
(7) The second line of the response contains “Content-type: text\html”
(8) The content of the requested fil follows next.

The Java code: Its in process. Now Version 0.2 (Released under GNU GPL) Read the rest of this entry »