<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>coffeewithcode | a sip of programming</title>
	
	<link>http://coffeewithcode.com</link>
	<description>a sip of programming</description>
	<lastBuildDate>Wed, 13 Mar 2013 19:27:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/coffeewithcode" /><feedburner:info uri="coffeewithcode" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Ant | How To Create Executable Jar ?</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/1du80NjJ2pU/</link>
		<comments>http://coffeewithcode.com/2013/03/ant-how-to-create-executable-jar/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 19:27:05 +0000</pubDate>
		<dc:creator>Coffee</dc:creator>
				<category><![CDATA[Ant]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=953</guid>
		<description><![CDATA[In this article I am going to describe about how to create executable jar file using ant file. For this I am using a java project with an ant file. In my previous post I have detailed how to create ant hello world ant project. I will use the same project here as well. To [...]]]></description>
				<content:encoded><![CDATA[<p>In this article I am going to describe about how to create executable jar file using ant file.</p>
<p>For this I am using a java project with an ant file.</p>
<p>In my previous post I have detailed <a title="how to create ant hello world project" href="http://coffeewithcode.com/2013/03/ant-hello-world-ant-project/" target="_blank">how to create ant hello world ant project</a>.</p>
<p>I will use the same project here as well.</p>
<p>To create an executable jar file one need to edit projectBuilder.xml file.</p>
<p>So new projectBuilder.xml will looks like as below:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="XML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span></li><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;AntProject&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;makejar&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;makejar&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Create a jar for the HW project&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jar</span> <span style="color: #000066;">jarfile</span>=<span style="color: #ff0000;">&quot;HelloWorld.jar&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;*.class&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;bin&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></li><li> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Main-Class&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Main&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></li><li> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></li><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></li><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></li><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now run this ant file right click and run as Ant build.</p>
<p>Here I added a manifest tag with Main-class in jar tag.</p>
<p>This will set Main-Class in MANIFEST.MF</p>
<p>One can see the Manidest.MF by double click on HelloWorld.jar&#8211;&gt;META-INF&#8211;&gt;Manifest.MF As below:</p>
<p><em>Manifest-Version: 1.0</em></p>
<p><em>Ant-Version: Apache Ant 1.8.3</em></p>
<p><em>Created-By: 1.6.0_18-b07 (Sun Microsystems Inc.)</em></p>
<p><em>Main-Class: Main</em></p>
<p>One can also execute HelloWorld.jar on the command line as below.</p>
<p><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/result.jpg"><img class="alignleft  wp-image-955" alt="result" src="http://coffeewithcode.com/wp-content/uploads/2013/03/result.jpg" width="534" height="84" /></a></p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/1du80NjJ2pU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2013/03/ant-how-to-create-executable-jar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2013/03/ant-how-to-create-executable-jar/</feedburner:origLink></item>
		<item>
		<title>Ant | Hello World Ant Project</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/BLfHbH8ReKg/</link>
		<comments>http://coffeewithcode.com/2013/03/ant-hello-world-ant-project/#comments</comments>
		<pubDate>Wed, 13 Mar 2013 11:20:35 +0000</pubDate>
		<dc:creator>Sanjay Jain</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=947</guid>
		<description><![CDATA[Apache Ant is an open source, cross-platform based build tool that is used to describe a build &#160;process and its dependencies and implemented in XML scripts using Java classes that ensures its&#160;extensible&#160;to any development environment (based on Java) and its &#160;integrity with other build tools. This article is about how to start with ant tool. [...]]]></description>
				<content:encoded><![CDATA[<p>Apache Ant is an open source, cross-platform based build tool that is used to describe a build &nbsp;process and its dependencies and implemented in XML scripts using Java classes that ensures its&nbsp;extensible&nbsp;to any development environment (based on Java) and its &nbsp;integrity with other build tools.</p>
<p>This article is about how to start with ant tool. In this article I am going to create a Java Project and will create a jar file &nbsp;of &nbsp;java project using ant file.</p>
<p>In my previous post I have written about <a title="Eclipse | Hello World Java Project" href="http://coffeewithcode.com/2013/03/eclipse-hello-world-java-project/" target="_blank">Eclipse | Hello World Java Project</a>. I am &nbsp;going to use same project and here also.</p>
<p>So my project structure will be as below:</p>
<p><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/pro.jpg"><img class="size-full wp-image-948  alignleft" alt="" src="http://coffeewithcode.com/wp-content/uploads/2013/03/pro.jpg" width="346" height="132" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Now to introduce ant file create a xml file using File&#8211;&gt; New wizard and &nbsp;name it projectBuilder.xml and place below code in xml file.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="XML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;AntProject&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;makejar&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> name =<span style="color: #ff0000;">&quot;makejar&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Create a jar for the ant project&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></li><li>&nbsp;&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jar</span> <span style="color: #000066;">jarfile</span>=<span style="color: #ff0000;">&quot;HelloWorld.jar&quot;</span> <span style="color: #000066;">includes</span>=<span style="color: #ff0000;">&quot;*.class&quot;</span> <span style="color: #000066;">basedir</span>=<span style="color: #ff0000;">&quot;bin&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></li><li> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></li><li><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><em id="__mceDel">&nbsp;&nbsp;<br />
</em>Now right click on projectbuilder.xml select run as ant file. As the execution stops refresh the ant project.<br />
A jar file named HelloWorld.jar will be in root project folder.</p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/BLfHbH8ReKg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2013/03/ant-hello-world-ant-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2013/03/ant-hello-world-ant-project/</feedburner:origLink></item>
		<item>
		<title>Eclipse | Hello World Java Project</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/JVBi_yQL2ww/</link>
		<comments>http://coffeewithcode.com/2013/03/eclipse-hello-world-java-project/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 18:14:12 +0000</pubDate>
		<dc:creator>Sanjay Jain</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=922</guid>
		<description><![CDATA[This article is abut how to start with eclipse hello world java project. Prerequisite: Java must be installed. In eclipse click on File -&#62; New Project -&#62; Java Project (as below) It will open new java project wizard. (as below) Enter a valid a project name in project name text box. Click next (or one [...]]]></description>
				<content:encoded><![CDATA[<p>This article is abut how to start with eclipse hello world java project.</p>
<p>Prerequisite: Java must be installed.</p>
<p>In eclipse click on File -&gt; New Project -&gt; Java Project (as below)</p>
<p style="text-align: center;"><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/1.jpg" target="_blank"><img class="size-full wp-image-923 aligncenter" alt="1" src="http://coffeewithcode.com/wp-content/uploads/2013/03/1.jpg" width="499" height="599" /></a></p>
<p>It will open new java project wizard. (as below)</p>
<p>Enter a valid a project name in project name text box. Click next (or one can directly click on finish also)</p>
<p style="text-align: left;"><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/2.jpg"><img class="size-full wp-image-924 aligncenter" alt="2" src="http://coffeewithcode.com/wp-content/uploads/2013/03/2.jpg" width="502" height="620" /></a></p>
<p style="text-align: left;">Click on finish on next wizard page. (as below)</p>
<p style="text-align: left;"><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/3.jpg"><img class="size-full wp-image-925 aligncenter" alt="3" src="http://coffeewithcode.com/wp-content/uploads/2013/03/3.jpg" width="502" height="595" /></a></p>
<p style="text-align: left;">Now create a new java class in src package.&nbsp;</p>
<p style="text-align: left;"><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/4.jpg"><img class="size-full wp-image-926 aligncenter" alt="4" src="http://coffeewithcode.com/wp-content/uploads/2013/03/4.jpg" width="563" height="617" /></a></p>
<p style="text-align: left;">On click of class will open a page for new class entry. Enter valid class name in name text box.</p>
<p style="text-align: left;">Also check main method check box as below. It will create a main method in class itself.</p>
<p style="text-align: center;"><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/5.jpg"><img class="size-full wp-image-927 aligncenter" alt="5" src="http://coffeewithcode.com/wp-content/uploads/2013/03/5.jpg" width="502" height="605" /></a></p>
<p style="text-align: justify;">Now a add sys out statement in main method. (as below)</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span></li><li> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+system"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello World !!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li> <span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p style="text-align: justify;">Noe one can run this as java application. (as below)</p>
<p style="text-align: left;"><a href="http://coffeewithcode.com/wp-content/uploads/2013/03/6.jpg"><img class=" wp-image-928 aligncenter" alt="6" src="http://coffeewithcode.com/wp-content/uploads/2013/03/6.jpg" width="555" height="417" /></a></p>
<p style="text-align: left;">It will first compile and then run TestProject application.</p>
<p>On console it will print result. &#8216;Hello World !!!&#8217;</p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/JVBi_yQL2ww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2013/03/eclipse-hello-world-java-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2013/03/eclipse-hello-world-java-project/</feedburner:origLink></item>
		<item>
		<title>How To Open New Tab For HTML Hyperlink ?</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/ll9dV6zx7MQ/</link>
		<comments>http://coffeewithcode.com/2013/03/how-to-open-new-tab-for-html-hyperlink/#comments</comments>
		<pubDate>Fri, 08 Mar 2013 21:31:09 +0000</pubDate>
		<dc:creator>Coffee</dc:creator>
				<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=919</guid>
		<description><![CDATA[HTML Hyperlink In HTML, hyperlink can be used by using &#60;a&#62; tag. Hyperlink is a group of word which can be clicked and get executed by opening clicked link. Syntax of HTML hyperlink is as below:&#160; &#60;a href=&#34;http://www.coffeewithcode.com/&#34;&#62;Visit coffeewithcode&#60;/a&#62; Here &#8216;Visit coffeewithcode&#8217; text can be clicked together and for this clickable text destination is http://www.coffeewithcode.com [...]]]></description>
				<content:encoded><![CDATA[<p><span style="color: #ff0000;">HTML</span> Hyperlink</p>
<p>In HTML, hyperlink can be used by using &lt;a&gt; tag. Hyperlink is a group of word which can be clicked and get executed by opening clicked link.</p>
<p>Syntax of HTML hyperlink is as below:&nbsp;</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.coffeewithcode.com/&quot;</span>&gt;</span>Visit coffeewithcode<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Here &#8216;Visit coffeewithcode&#8217; text can be clicked together and for this clickable text destination is http://www.coffeewithcode.com which is described in href attribute of &lt;a&gt; tag. So on click of Visit coffeewithcode it will open http://www coffeewithcode.com in same tab / browser.</p>
<p>In case if once required to open hyperlink in new tab / browser window then also it is possible.</p>
<p>For this one need to add new attribute <em>target</em>&nbsp;and value for this attribute is &#8220;_blank&#8221;.<em><strong><br />
</strong></em></p>
<p>So new syntax will be as below:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.coffeewithcode.com/&quot;</span> <span style="color: #000066;">target</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;_blank&quot;</span>&gt;</span>Visit coffeewithcode<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now on click on &#8216;Visit coffeewithcode&#8217; will open http://www coffeewithcode.com&nbsp;in new tab / windows.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/ll9dV6zx7MQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2013/03/how-to-open-new-tab-for-html-hyperlink/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2013/03/how-to-open-new-tab-for-html-hyperlink/</feedburner:origLink></item>
		<item>
		<title>How to install Oracle libraries for PHP5 on Ubuntu Server</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/lfJbmRAVVok/</link>
		<comments>http://coffeewithcode.com/2012/09/how-to-install-oracle-libraries-for-php5-on-ubuntu-server/#comments</comments>
		<pubDate>Sun, 30 Sep 2012 16:56:05 +0000</pubDate>
		<dc:creator>Coffee</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=882</guid>
		<description><![CDATA[An easy way to Connect Apache server (PHP) with Oracle database. Execute following command in terminal to complete installation of oracle OCI8 extension in php.ini. 1) Get Oracle repository from this link. &#160; &#160;&#160; http://oss.oracle.com/debian unstable main non-free 2) Make sure to add the proper GPG key for the repository. &#160;&#160;&#160;&#160;&#160; sudo wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- [...]]]></description>
				<content:encoded><![CDATA[<p><strong>An easy way to Connect Apache server (PHP) with Oracle database.</strong><strong></strong></p>
<p><strong>Execute following command in terminal to complete installation of oracle OCI8 extension in php.ini.</strong></p>
<p><strong>1) </strong><strong>Get Oracle repository from this link.</strong></p>
<p>&nbsp; &nbsp;&nbsp; <a title="http://oss.oracle.com/debian" href="http://oss.oracle.com/debian">http://oss.oracle.com/debian</a> unstable main non-free</p>
<p><strong>2) </strong><strong>Make sure to add the proper GPG key for the repository.</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo wget <a title="http://oss.oracle.com/el4/RPM-GPG-KEY-oracle" href="http://oss.oracle.com/el4/RPM-GPG-KEY-oracle">http://oss.oracle.com/el4/RPM-GPG-KEY-oracle</a> -O- | sudo apt-key add -</p>
<p><strong>3) Get all the packages for PHP5, Oracle, and Apache2 server.</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get update</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get install build-essential</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get install php5-dev</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get install php5</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get install php-pear</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get install oracle-xe-client</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get install apache2</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo apt-get install libapache2-mod-php5</p>
<p><strong>4) Install Oracle OCI8 library.</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pecl install oci8</p>
<p><strong>5) This will ask for your home directory. At the time of installing the Oracle client was installed in following path :</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; /usr/lib/oracle/xe/app/oracle/product/10.2.0/client/</p>
<p><strong>6) When the installation is complete you will need to add the extension information to both instance of php.ini.</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;extension=oci8.so&#8221; &gt;&gt; /etc/php5/cli/php.ini</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; echo &#8220;extension=oci8.so&#8221; &gt;&gt; /etc/php5/apache2/php.ini</p>
<p><strong>7) Restart Apache2 server. </strong></p>
<p>&nbsp;&nbsp; &nbsp;/etc/init.d/apache2 restart</p>
<p><strong>Now make a simple test to find oracle connectivity with php.</strong></p>
<p><strong>Make test.php and paste following&nbsp; code.</strong></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">&lt;?php</span></li><li><span style="color: #666666; font-style: italic;">//oracle connection variables</span></li><li><span style="color: #000088;">$ora_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'USER_NAME'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//username</span></li><li><span style="color: #000088;">$ora_pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'PASSWORD'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//password</span></li><li><span style="color: #000088;">$ora_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'SERVER_IP_OF_ORACLE&quot;'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//host name or server ip address</span></li><li><span style="color: #000088;">$ora_db</span> <span style="color: #339933;">=</span> ‘DATABASE_NAME<span style="color: #0000ff;">'; //database name</span></li><li>&nbsp;</li><li><span style="color: #0000ff;">$conn = oci_connect($ora_user,$ora_pass,'</span><span style="color: #666666; font-style: italic;">//'.$ora_host.'/'.$ora_db);</span></li><li>&nbsp;</li><li><span style="color: #666666; font-style: italic;">// error handling</span></li><li><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ora_conn<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// if variable $conn fails to connect</span></li><li><span style="color: #666666; font-style: italic;">// do the following if it fails</span></li><li><span style="color: #000088;">$ora_conn_erno</span> <span style="color: #339933;">=</span> oci_error<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// insert oci_error() function into variable</span></li><li><span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ora_conn_erno</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// print the $ora_conn_erno variable/oci_error() function selecting only the message (human readable)</span></li><li>oci_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// close the connection just in case php doesn't close it</span></li><li><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span></li><li><span style="color: #666666; font-style: italic;">// if it doesn't fail it will proceed with the rest of the script</span></li><li><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Connection Successful<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//echo message if connection does not error</span></li><li>oci_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// close the connection</span></li><li><span style="color: #009900;">&#125;</span></li><li><span style="color: #000000; font-weight: bold;">?&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/lfJbmRAVVok" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2012/09/how-to-install-oracle-libraries-for-php5-on-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2012/09/how-to-install-oracle-libraries-for-php5-on-ubuntu-server/</feedburner:origLink></item>
		<item>
		<title>Php code for twitter interaction</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/aLIFC2J-wVg/</link>
		<comments>http://coffeewithcode.com/2012/07/php-code-for-twitter-interaction/#comments</comments>
		<pubDate>Thu, 19 Jul 2012 05:22:22 +0000</pubDate>
		<dc:creator>vimal</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=876</guid>
		<description><![CDATA[Let’s take a look how php code interacts with twitter. 1.) How to get number of &#160;twitter followers. fnction get_followers&#40;$twitter_id&#41;&#123;&#160;&#160;&#160;&#160;$xml=file_get_contents&#40;'http://twitter.com/users/show.xml?screen_name='.$twitter_id&#41;;&#160;&#160;&#160;&#160;if &#40;preg_match&#40;'/followers_count&#62;(.*)&#60;/',$xml,$match&#41;!=0&#41; &#123;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;$tw&#91;'count'&#93; = $match&#91;1&#93;;&#160;&#160;&#160;&#160;&#125;&#160;&#160;&#160;&#160;&#160;return $tw&#91;'count'&#93;;&#125; Now call this function with this code $followers = get_followers&#40;‘vimalm4u’&#41;;echo “You have”.$followers.”followers!”; 2.) Get number of retweets for a specific page. &#160;&#160;&#160;&#160;&#160;&#160; Function will get the number of &#160;retweets of [...]]]></description>
				<content:encoded><![CDATA[<h3>Let’s take a look how php code interacts with twitter.</h3>
<h3>1.) How to get number of &nbsp;twitter followers.</h3>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li>fnction get_followers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$twitter_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$xml</span><span style="color: #339933;">=</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://twitter.com/users/show.xml?screen_name='</span><span style="color: #339933;">.</span><span style="color: #000088;">$twitter_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/followers_count&gt;(.*)&lt;/'</span><span style="color: #339933;">,</span><span style="color: #000088;">$xml</span><span style="color: #339933;">,</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000088;">$tw</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #b1b100;">return</span> <span style="color: #000088;">$tw</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now call this function with this code</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li><span style="color: #000088;">$followers</span> <span style="color: #339933;">=</span> get_followers<span style="color: #009900;">&#40;</span>‘vimalm4u’<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><span style="color: #b1b100;">echo</span> “You have”<span style="color: #339933;">.</span><span style="color: #000088;">$followers</span><span style="color: #339933;">.</span>”followers<span style="color: #339933;">!</span>”<span style="color: #339933;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<h3>2.) Get number of retweets for a specific page.</h3>
<p id="internal-source-marker_0.6124762243745759" dir="ltr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function will get the number of &nbsp;retweets of the url passed as a parameter</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">function</span> rtweetCount<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp; <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://api.tweetmeme.com/url_info?url=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp; <span style="color: #000088;">$element</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleXmlElement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp; <span style="color: #000088;">$retweets</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$element</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">story</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url_count</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$retweets</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$retweets</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp; <span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li><span style="color: #b1b100;">echo</span> rtweetCount<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.coffeewithcode.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<h3 id="internal-source-marker_0.6124762243745759" dir="ltr">3) Shorten urls for Twitter</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As we know, we can’t tweets messages which are longer than 140 characters. To avoid this problem, you have to use an url shortener.</p>
<p>&nbsp;</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="PHP"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">function</span> getTinyUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://tinyurl.com/api-create.php?url=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/aLIFC2J-wVg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2012/07/php-code-for-twitter-interaction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2012/07/php-code-for-twitter-interaction/</feedburner:origLink></item>
		<item>
		<title>How To Call A Java Script From Java Code?</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/r2OwMOXY-JQ/</link>
		<comments>http://coffeewithcode.com/2012/06/how-to-call-a-java-script-from-java-code/#comments</comments>
		<pubDate>Fri, 29 Jun 2012 11:49:44 +0000</pubDate>
		<dc:creator>Sanjay Jain</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=863</guid>
		<description><![CDATA[This post is to describe how to call a java script&#160;from java code. Below is &#160;java file.In which there is a main method.In this main method a script engine instance is taken.This script engine is already with jdk.For this one need not to add any other jar file. import java.io.FileNotFoundException;import java.io.FileReader;&#160;import javax.script.ScriptEngine;import javax.script.ScriptEngineManager;import javax.script.ScriptException;&#160;public class [...]]]></description>
				<content:encoded><![CDATA[<p>This post is to describe how to call a <span style="color: #ff0000;">java script</span>&nbsp;from <span style="color: #ff0000;">java</span> code.</p>
<p>Below is &nbsp;java file.In which there is a main method.In this main method a script engine instance is taken.This script engine is already with jdk.For this one need not to add any other jar file.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileNotFoundException</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileReader</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.script.ScriptEngine</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.script.ScriptEngineManager</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.script.ScriptException</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+driver"><span style="color: #003399;">Driver</span></a> <span style="color: #009900;">&#123;</span></li><li>&nbsp;</li><li><span style="color: #008000; font-style: italic; font-weight: bold;">/**</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">* @param args</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">* @throws FileNotFoundException</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">*/</span></li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+filenotfoundexception"><span style="color: #003399;">FileNotFoundException</span></a> <span style="color: #009900;">&#123;</span></li><li><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">/**</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">* To call a anonymous function from java script file</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">*/</span></li><li>ScriptEngine engine <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ScriptEngineManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li>.<span style="color: #006633;">getEngineByName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;javascript&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+filereader"><span style="color: #003399;">FileReader</span></a> fr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+filereader"><span style="color: #003399;">FileReader</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;src/js/MySpec.js&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>engine.<span style="color: #006633;">eval</span><span style="color: #009900;">&#40;</span>fr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ScriptException scrEx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li>scrEx.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Below is the java script file with an anonymous fuction.This function is to print on the console.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Javascript"><div class="devcodeoverflow"><ol><li><span style="color: #006600; font-style: italic;">// java script anonumous function</span></li><li><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li> print<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello world'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Below is the folder structure of the project.</p>
<div id="attachment_864" class="wp-caption aligncenter" style="width: 244px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/js_to_java.png"><img class="size-full wp-image-864" title="js_to_java" src="http://coffeewithcode.com/wp-content/uploads/2012/06/js_to_java.png" alt="Folder Structure" width="234" height="125" /></a><p class="wp-caption-text">Folder Structure</p></div>
<p><span style="color: #808080;">Your Suggestions Are Always Welcomed.</span></p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/r2OwMOXY-JQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2012/06/how-to-call-a-java-script-from-java-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2012/06/how-to-call-a-java-script-from-java-code/</feedburner:origLink></item>
		<item>
		<title>Hibernate plugin in eclipse</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/UplxFRTx1g4/</link>
		<comments>http://coffeewithcode.com/2012/06/844/#comments</comments>
		<pubDate>Wed, 20 Jun 2012 09:14:30 +0000</pubDate>
		<dc:creator>Sanjay Jain</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Hibernate Configuration Properties]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=844</guid>
		<description><![CDATA[In previous post I describe about how to hibernate plugin the eclipse.In this post I am detailing about how that plugin will be helpful in development. While creating any new hibernate related file this plugin will help you by configuring the parameter which are necessary to create that file. Below are the suggestion by hibernate [...]]]></description>
				<content:encoded><![CDATA[<p>In previous post I describe about how to <span style="color: #ff0000;">hibernate</span> plugin the eclipse.In this post I am detailing about how that plugin will be helpful in development.</p>
<p>While creating any new hibernate related file this plugin will help you by configuring the parameter which are necessary to create that file.</p>
<p>Below are the suggestion by hibernate plugin in the new wizards.</p>
<div id="attachment_845" class="wp-caption aligncenter" style="width: 533px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hibernateplugin0.png"><img class="size-full wp-image-845" title="hibernateplugin0" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hibernateplugin0.png" alt="Hibernate plugin in eclipse" width="523" height="515" /></a><p class="wp-caption-text">Hibernate plugin in eclipse</p></div>
<p>On click of any of four link it will start a new wizard.New wizard will ask for the required input parameter to build respective file.By using this wizard one need not to create specific file manually and do entries.</p>
<p>While working with hibernate mapping file hibernate plugin also help with suggestions of bean properties.</p>
<p>There may many other features of hibernate plugin which are helpful at the time of development.As I came across I will share them on this blog.</p>
<p>Above are the benefits at the time of the development.Hibernate plugins also provide a complete hibernate tutorial inside the eclipse with examples.</p>
<p>To see the hibernate tutorial inside the eclipse go to</p>
<ul>
<li>Help</li>
<li>Help Contents</li>
</ul>
<p>It will open a new windows.This contains the guide to develop hibernate application with examples.</p>
<p>Here below is the screenshot of newly opened window:</p>
<div id="attachment_855" class="wp-caption aligncenter" style="width: 521px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hibernateplugin12.png"><img class="size-full wp-image-855" title="hibernateplugin1" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hibernateplugin12.png" alt="Hibernate plugin in eclipse" width="511" height="611" /></a><p class="wp-caption-text">Hibernate plugin in eclipse</p></div>
<p><span style="color: #808080;">Your Suggestions Are Always Welcomed.</span></p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/UplxFRTx1g4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2012/06/844/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2012/06/844/</feedburner:origLink></item>
		<item>
		<title>How to install hibernate plugin in eclipse?</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/TVQSU0y6a9U/</link>
		<comments>http://coffeewithcode.com/2012/06/how-to-install-hibernate-plugin-in-eclipse/#comments</comments>
		<pubDate>Wed, 20 Jun 2012 05:36:21 +0000</pubDate>
		<dc:creator>Sanjay Jain</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Hibernate Configuration Properties]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=831</guid>
		<description><![CDATA[This article is about how to install hibernate plugin / tools in eclipse. To install hibernate plugin / tools in eclipse one need to follow below steps. Go to help menu in eclipse Install new software (This will vary in different eclipse version) Click on Add site In location text box paste following url &#160;&#160; [...]]]></description>
				<content:encoded><![CDATA[<p>This article is about how to install <span style="color: #ff0000;">hibernate </span>plugin / tools in <span style="color: #ff0000;">eclipse</span>.</p>
<p>To install hibernate plugin / tools in eclipse one need to follow below steps.</p>
<ul>
<li>Go to help menu in eclipse</li>
<li>Install new software (This will vary in different eclipse version)</li>
</ul>
<div>
<div id="attachment_834" class="wp-caption aligncenter" style="width: 310px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber0.png"><img class="size-medium wp-image-834" title="hiber0" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber0-300x151.png" alt="Hibernate plugin installation in eclipse" width="300" height="151" /></a><p class="wp-caption-text">Hibernate plugin installation in eclipse</p></div>
</div>
<ul>
<li>Click on Add site</li>
</ul>
<div>
<div id="attachment_835" class="wp-caption aligncenter" style="width: 285px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber1.png"><img class="size-medium wp-image-835" title="hiber1" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber1-275x300.png" alt="Hibernate plugin installation in eclipse" width="275" height="300" /></a><p class="wp-caption-text">Hibernate plugin installation in eclipse</p></div>
</div>
<ul>
<li>In location text box paste following url &nbsp;&nbsp;</li>
</ul>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a title="hibernate plugin url" href="http://download.jboss.org/jbosstools/updates/stable/" target="_blank">&nbsp;http://download.jboss.org/jbosstools/updates/stable/</a></p>
<div id="attachment_836" class="wp-caption aligncenter" style="width: 310px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber5.png"><img class="size-medium wp-image-836" title="hiber5" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber5-300x142.png" alt="Hibernate plugin installation in eclipse" width="300" height="142" /></a><p class="wp-caption-text">Hibernate plugin installation in eclipse</p></div>
<ul>
<li>It will show all the jBoss software to install.If you only want to install hibernate plugin then in search text box type hibernate.It will filter out only hibernate related plugins.</li>
</ul>
<div>
<div id="attachment_838" class="wp-caption aligncenter" style="width: 277px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber2.png"><img class="size-medium wp-image-838" title="hiber2" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber2-267x300.png" alt="Hibernate plugin installation in eclipse" width="267" height="300" /></a><p class="wp-caption-text">Hibernate plugin installation in eclipse</p></div>
</div>
<ul>
<li>Click next to install&nbsp;&nbsp;(May be it will take some time to install the plugin (I f you are facing error in installing the hibernate plugin at this stage then there is a check box in above screen named contact all update site during install to find required software, please check it. It will resolve all the resolve required dependency.)</li>
</ul>
<ul>
<li>Once installed it will ask to restart the eclipse.</li>
<li>After restart one can verify it.</li>
</ul>
<ul>
<li>To verify:</li>
<li>Go to windows</li>
<li>Open perspective</li>
<li>In other option you can see the hibernate</li>
</ul>
<div>
<div id="attachment_839" class="wp-caption aligncenter" style="width: 310px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber3.png"><img class="size-medium wp-image-839" title="hiber3" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber3-300x275.png" alt="Hibernate plugin installation in eclipse" width="300" height="275" /></a><p class="wp-caption-text">Hibernate plugin installation in eclipse</p></div>
</div>
<p>This plugin is helpful while creating the hibernate file in new wizard.</p>
<div id="attachment_842" class="wp-caption aligncenter" style="width: 263px"><a href="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber6.png"><img class="size-medium wp-image-842" title="hiber6" src="http://coffeewithcode.com/wp-content/uploads/2012/06/hiber6-253x300.png" alt="Hibernate plugin installation in eclipse" width="253" height="300" /></a><p class="wp-caption-text">Hibernate plugin installation in eclipse</p></div>
<p><span style="color: #808080;">Your Suggestions Are Always Welcomed.</span></p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/TVQSU0y6a9U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2012/06/how-to-install-hibernate-plugin-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2012/06/how-to-install-hibernate-plugin-in-eclipse/</feedburner:origLink></item>
		<item>
		<title>Hibernate Hello World Example With Annotation</title>
		<link>http://feedproxy.google.com/~r/coffeewithcode/~3/SgQglKgTq5g/</link>
		<comments>http://coffeewithcode.com/2012/06/hibernate-hello-world-example-with-annotation/#comments</comments>
		<pubDate>Mon, 18 Jun 2012 12:33:19 +0000</pubDate>
		<dc:creator>Sanjay Jain</dc:creator>
				<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Hibernate Example]]></category>

		<guid isPermaLink="false">http://coffeewithcode.com/?p=822</guid>
		<description><![CDATA[This article is about&#160;hibernate&#160;practical example. Below is an example of hibernate with my sql using hibernate annotations. Here is the Student bean class with id and name properties with annotations.&#160; package beans;&#160;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.Id;import javax.persistence.Table;&#160;@Entity@Table&#40;name=&#34;student_master&#34;&#41;public class Student&#160;&#160;&#123;&#160; @Id @GeneratedValue @Column&#40;name=&#34;stud_id&#34;&#41; private long id;&#160; @Column&#40;name=&#34;name&#34;&#41; private String name;&#160; /**&#160; * getters and setters&#160; * [...]]]></description>
				<content:encoded><![CDATA[<p>This article is about&nbsp;<span style="color: #ff0000;">hibernate&nbsp;</span>practical example. Below is an example of hibernate with my sql using hibernate annotations.</p>
<p>Here is the Student bean class with id and name properties with annotations.&nbsp;</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">beans</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Column</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.GeneratedValue</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>@<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+entity"><span style="color: #003399;">Entity</span></a></li><li>@Table<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;student_master&quot;</span><span style="color: #009900;">&#41;</span></li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Student&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;</li><li> @Id</li><li> @GeneratedValue</li><li> @Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stud_id&quot;</span><span style="color: #009900;">&#41;</span></li><li> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> id<span style="color: #339933;">;</span></li><li>&nbsp;</li><li> @Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span></li><li> <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> name<span style="color: #339933;">;</span></li><li>&nbsp;</li><li> <span style="color: #008000; font-style: italic; font-weight: bold;">/**</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">&nbsp; * getters and setters</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">&nbsp; * @return</span></li><li><span style="color: #008000; font-style: italic; font-weight: bold;">&nbsp; */</span></li><li> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li> <span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span></li><li> <span style="color: #009900;">&#125;</span></li><li> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">long</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span></li><li> <span style="color: #009900;">&#125;</span></li><li> <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li> <span style="color: #000000; font-weight: bold;">return</span> name<span style="color: #339933;">;</span></li><li> <span style="color: #009900;">&#125;</span></li><li> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setName<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+string"><span style="color: #003399;">String</span></a> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></li><li> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span></li><li> <span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Here is the hibernate.cfg.xml file. For this example mysql used as the data base.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;?xml <span style="color: #000066;">version</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'1.0'</span> encoding<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'utf-8'</span>?&gt;</span></li><li><span style="color: #00bbdd;">&lt;!DOCTYPE hibernate-configuration PUBLIC</span></li><li><span style="color: #00bbdd;">&quot;-//Hibernate/Hibernate Configuration DTD//EN&quot;</span></li><li><span style="color: #00bbdd;">&quot;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;&gt;</span></li><li>&nbsp;</li><li><span style="color: #009900;">&lt;hibernate-configuration&gt;</span></li><li> <span style="color: #009900;">&lt;session-factory&gt;</span></li><li> <span style="color: #009900;">&lt;property <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hibernate.connection.driver_class&quot;</span>&gt;</span>com.mysql.jdbc.Driver<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>property&gt;</span></li><li> <span style="color: #009900;">&lt;property <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hibernate.connection.url&quot;</span>&gt;</span>jdbc:mysql://localhost:3306/test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>property&gt;</span></li><li> <span style="color: #009900;">&lt;property <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hibernate.connection.username&quot;</span>&gt;</span>root<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>property&gt;</span></li><li> <span style="color: #009900;">&lt;property <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hibernate.connection.password&quot;</span>&gt;</span>root<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>property&gt;</span></li><li> <span style="color: #009900;">&lt;property <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;show_sql&quot;</span>&gt;</span>true<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>property&gt;</span></li><li> <span style="color: #009900;">&lt;property <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hibernate.hbm2ddl.auto&quot;</span>&gt;</span>create<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>property&gt;</span></li><li> <span style="color: #009900;">&lt;property <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dialect&quot;</span>&gt;</span>org.hibernate.dialect.MySQLDialect<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>property&gt;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;mapping <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;beans.Student&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></li><li> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>session-factory&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>hibernate-configuration&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Here is the Driver class. In the driver class we have created an instance of student and saved to the database.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li>package driver;</li><li>&nbsp;</li><li>import org.hibernate.Session;</li><li>import org.hibernate.SessionFactory;</li><li>import org.hibernate.cfg.Configuration;</li><li>&nbsp;</li><li>import beans.Student;</li><li>&nbsp;</li><li>public class Driver {</li><li> /**</li><li>&nbsp;&nbsp;* main method</li><li>&nbsp;&nbsp;*/</li><li> public static void main(String[] args) {</li><li> Session session = null;</li><li> try {</li><li> //getting session factory instance</li><li> SessionFactory sessionFactory = new Configuration().configure(</li><li> &quot;hibernate/hibernate.cfg.xml&quot;).buildSessionFactory();</li><li> session = sessionFactory.openSession();</li><li> session.beginTransaction();</li><li> //student instance</li><li> Student student = new Student();</li><li> student.setName(&quot;Sanjay &quot;);</li><li> session.save(student);</li><li> session.getTransaction().commit();</li><li> } catch (Exception e) {</li><li> System.out.println(e.getMessage());</li><li> } finally {</li><li> session.flush();</li><li> session.close();</li><li> }</li><li> }</li><li>}</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><span style="color: #808080;">Your Suggestions Are Always Welcomed.</span></p>
<img src="http://feeds.feedburner.com/~r/coffeewithcode/~4/SgQglKgTq5g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://coffeewithcode.com/2012/06/hibernate-hello-world-example-with-annotation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://coffeewithcode.com/2012/06/hibernate-hello-world-example-with-annotation/</feedburner:origLink></item>
	</channel>
</rss>
