<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Praveen Arimbrathodiyil blogs here &#187; Java</title>
	<atom:link href="http://www.j4v4m4n.in/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.j4v4m4n.in</link>
	<description>It's My life</description>
	<lastBuildDate>Wed, 01 Feb 2012 21:13:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Java is Free! Thank You Sun.</title>
		<link>http://www.j4v4m4n.in/2006/11/13/java-is-free-thank-you-sun/</link>
		<comments>http://www.j4v4m4n.in/2006/11/13/java-is-free-thank-you-sun/#comments</comments>
		<pubDate>Mon, 13 Nov 2006 16:05:21 +0000</pubDate>
		<dc:creator>Praveen A</dc:creator>
				<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.j4v4m4n.in/2006/11/13/java-is-free-thank-you-sun/</guid>
		<description><![CDATA[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. It’s an example I hope others will follow. &#8211; Dr. Richard Stallman, Founder of GNU Project and Free Software Foundation This is indeed great [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sun.com/opensource/java/">Java is Free</a>!</p>
<blockquote><p>I think Sun has well, with this contribution have contributed more than any other company to the free<br />
software community in the form of software. It shows leadership. It’s an example I hope others will follow.<br />
&#8211; Dr. Richard Stallman, Founder of GNU Project and Free Software Foundation</p></blockquote>
<p>This is indeed great victory for Free Software. A great part of this incredible progress is due to the great work of so many <a href="http://planet.classpath.org">Free Java hackers</a>.  The runtime, compilers and GlassFish Aplication server will be available under GPLv2 and the libraries under GPLv2+classpath exception.</p>
<p>&#8211;j4v4m4n (that is my IRC nick and what my friends call me, so it is even a personal victory for me!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4v4m4n.in/2006/11/13/java-is-free-thank-you-sun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java programming with gcj</title>
		<link>http://www.j4v4m4n.in/2006/09/24/java-programming-with-gcj/</link>
		<comments>http://www.j4v4m4n.in/2006/09/24/java-programming-with-gcj/#comments</comments>
		<pubDate>Sun, 24 Sep 2006 14:00:23 +0000</pubDate>
		<dc:creator>Praveen A</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.j4v4m4n.in/2006/09/24/java-programming-with-gcj/</guid>
		<description><![CDATA[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 $ [...]]]></description>
			<content:encoded><![CDATA[<p>    How to compile and run java programs using GCJ ?</p>
<p><code>$ gcj -C hello.java</code></p>
<p>is similar to javac hello.java and it creates a class file hello.class</p>
<p><code>$ gij hello</code></p>
<p>is similar to java as it executes  bytecode in hello.class</p>
<p>what gcj offers that is not available with reguar jdk is support for creating binaries</p>
<p><code>$ gcj hello.java --main=hello</code></p>
<p>or if you already have the class file<br />
<code><br />
$ gcj hello.class --main=hello</code></p>
<p>will create a binary file a.out and you can execute it using</p>
<p><code>$ ./a.out</code></p>
<p>it is similar to compiling with gcc and you can specify a different output file with -o option</p>
<p><code>$ gcj hello.java --main=hello -o hello<br />
$ ./hello</code></p>
<p>More information on gcj see <a href="http://gcc.gnu.org/java/">http://gcc.gnu.org/java/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4v4m4n.in/2006/09/24/java-programming-with-gcj/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Webserver inspired from Thejesh</title>
		<link>http://www.j4v4m4n.in/2005/08/12/java-webserver-inspired-from-thejesh/</link>
		<comments>http://www.j4v4m4n.in/2005/08/12/java-webserver-inspired-from-thejesh/#comments</comments>
		<pubDate>Fri, 12 Aug 2005 14:15:24 +0000</pubDate>
		<dc:creator>Praveen A</dc:creator>
				<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.j4v4m4n.in/2005/08/12/java-webserver-inspired-from-thejesh/</guid>
		<description><![CDATA[<a href="http://www.techmag.biz/?q=node/99">Here is Thejesh's page</a>

The requirement is (from thejesh's portal techmag.biz)

<blockquote>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.</blockquote>

The Java code: Its in process. Now Version 0.2 (Released under GNU GPL)<!--more-->]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.techmag.biz/?q=node/99">Here is Thejesh&#8217;s page</a></p>
<p>The requirement is (from thejesh&#8217;s portal techmag.biz)</p>
<blockquote><p>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.<br />
Let us keep it simple and serve only HTML pages and not GIF&#8217;s and JPEG&#8217;s.</p>
<p>Points to consider:<br />
(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.<br />
(2) Every webserver will have a root folder. Only the files under this root folder are accessible by the server.<br />
(3) We will serve only .htm or .html files<br />
(4) When we get the request. the first line of the request will contain the word &#8220;GET&#8221; followed by the file name.<br />
(5) The server should be multithreaded to handle multiple requests.<br />
(6) The first line of the response will be &#8220;HTTP/1.0 200 OK&#8221;<br />
(7) The second line of the response contains &#8220;Content-type: text\html&#8221;<br />
(8) The content of the requested fil follows next.</p></blockquote>
<p>The Java code: Its in process. Now Version 0.2 (Released under GNU GPL)<span id="more-72"></span><br />
<code><br />
import java.io.*;<br />
import java.net.*;</p>
<p>public class WebServer {<br />
    public static void main(String[] args) throws IOException {</p>
<p>        ServerSocket serverSocket = null;<br />
        System.out.println("WebServer started and is listening at port 80\n");<br />
        while(true){<br />
		try {<br />
     	       	serverSocket = new ServerSocket(80);<br />
       		 }<br />
	        catch(IOException e) {<br />
        	    System.err.println("Cannot open port at 80");<br />
	            System.exit(-1);<br />
        	}</p>
<p>	        Socket clientSocket = null;<br />
        	try {<br />
	            clientSocket = serverSocket.accept();<br />
        	}<br />
	        catch(IOException e) {<br />
        	    System.out.println("Accept Failed: 80");<br />
	            System.exit(-1);<br />
        	}</p>
<p>	        PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),true);<br />
        	BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));</p>
<p>	        String inputLine="GET / HTTP/1.1",outputLine;<br />
        	outputLine="&lt;html&gt;&lt;body&gt;&lt;h2&gt;Hello Ranganath&lt;/h2&gt;&lt;/body&gt;&lt;/html&gt;";</p>
<p>	       do {<br />
       		    try {<br />
	            inputLine=in.readLine();<br />
		    }catch (IOException e) {<br />
	    		System.out.println("Read Error");<br />
		    }<br />
        	    putOutputMessage(out);<br />
	            System.out.println(inputLine);</p>
<p>	            out.flush();<br />
		    out.close();<br />
	            in.close();<br />
        	    clientSocket.close();<br />
		    inputLine=null;</p>
<p>        	} while (inputLine != null);<br />
	        serverSocket.close();</p>
<p>	    }<br />
    }<br />
    static void putOutputMessage(PrintWriter out) throws IOException {<br />
    	File index=new File("www/index.html");<br />
	FileReader in = new FileReader(index);<br />
	int c;</p>
<p>	while((c=in.read()) !=-1) {<br />
		out.write(c);<br />
	}<br />
    }</p>
<p>}<br />
</code><br />
Change log</p>
<p>1. It can serve more than one requests (one after another &#8211; thread is not yet implemented). Used an infinite while loop <img src='http://www.j4v4m4n.in/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
2. It reads index.html from www folder (file name extraction from request is yet to be implemented)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4v4m4n.in/2005/08/12/java-webserver-inspired-from-thejesh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

