<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4794466813239776599</id><updated>2026-07-18T17:25:27.538-07:00</updated><category term="Java"/><category term="Comparable and Comparator"/><category term="Java Comparable and Comparator"/><category term="Java Comparator"/><category term="maven"/><category term="Base 64"/><category term="Base 64 Java"/><category term="Base64"/><category term="Base64 Java"/><category term="Base64 encoding"/><category term="Bill Pugh"/><category term="Bill Pugh&#39;s solution"/><category term="Comparator and Comparable"/><category term="Comparator demo"/><category term="Comparator example"/><category term="DES in java"/><category term="Data Encryption java"/><category term="Difference Comparable and Comparator"/><category term="Difference between ServletConfig and ServletContext"/><category term="Hibernate composite"/><category term="Hibernate composite key"/><category term="Hibernate composite primary key"/><category term="JAXB"/><category term="JAXB datatype"/><category term="JAXB datatype maping"/><category term="JVM memory"/><category term="JVM memory allocation"/><category term="JVM memory management"/><category term="JVM memory structure"/><category term="Java  Comparable"/><category term="Java Base 64"/><category term="Java Base64"/><category term="Java Base64 decoding"/><category term="Java Singleton"/><category term="Java interview questions"/><category term="Java tricky question"/><category term="MD5 java"/><category term="NetBeans RA layer request failed"/><category term="RA layer request failed"/><category term="Runtime Data Areas"/><category term="ServletConfig"/><category term="ServletContext"/><category term="Singleton"/><category term="Singleton Java"/><category term="Singleton design"/><category term="Singleton pattern"/><category term="System.out"/><category term="System.out.println"/><category term="adding favicon"/><category term="adding image to URL"/><category term="adding image to address bar"/><category term="crypto"/><category term="cryptography"/><category term="deployment descriptor"/><category term="des java"/><category term="design pattern"/><category term="difference runnable and thread java"/><category term="difference runnable thread"/><category term="difference runnable threads"/><category term="difference servletconfig servletcontext"/><category term="diffrence ServletContext ServletConfig"/><category term="email"/><category term="email validation"/><category term="equal to 4 5 6"/><category term="example jquery"/><category term="favicon"/><category term="heap"/><category term="heap memory"/><category term="heap memory in jvm"/><category term="heap memory java"/><category term="heap memory jvm"/><category term="how to find if in email adress is having at the rate and DOT ? java"/><category term="https"/><category term="https tomcat"/><category term="if i equal to 4 5 6"/><category term="interview tricky questions"/><category term="java 7"/><category term="java 7 bugs"/><category term="java System"/><category term="java base64 encode example"/><category term="java cryptography"/><category term="java des"/><category term="java design pattern"/><category term="java email validation"/><category term="java heap memory"/><category term="java logical questions"/><category term="java md5"/><category term="java md5 algo"/><category term="java news"/><category term="java practical questions"/><category term="java security"/><category term="java singleton pattern"/><category term="java static factory method"/><category term="java static factory method example"/><category term="java static factory method vs constructor"/><category term="java static method"/><category term="java system println"/><category term="java system println format"/><category term="java system.println example"/><category term="java thread"/><category term="java thread example"/><category term="java threads"/><category term="java tricky code"/><category term="java tricky programs"/><category term="java validation"/><category term="java validations"/><category term="java.lang.system"/><category term="java7"/><category term="jaxb data format"/><category term="jaxb data type mapping"/><category term="jaxb data types"/><category term="jaxb date"/><category term="jaxb date format"/><category term="jaxb mapping"/><category term="jaxb mapping list"/><category term="jquery"/><category term="jquery example"/><category term="jquery hello world"/><category term="jquery tutorial"/><category term="jvm heap"/><category term="jvm heap memory"/><category term="jvm heap tuning"/><category term="jvm memory architecture"/><category term="jvm tuning"/><category term="jvm tunning"/><category term="keystore"/><category term="keystore tomcat"/><category term="maven cusotm jar repository"/><category term="maven eclipse proxy setting"/><category term="maven proxy config"/><category term="maven proxy setting"/><category term="maven proxy setting not working"/><category term="maven repository"/><category term="md5 algo java"/><category term="number of objects to create"/><category term="number of objects to create Java"/><category term="oracle java 7"/><category term="oracle java 7 bugs"/><category term="org.tigris.subversion.javahl.ClientException"/><category term="org.tigris.subversion.javahl.ClientException: RA layer request failed"/><category term="runnable interface"/><category term="security java"/><category term="security tomcat"/><category term="ssl"/><category term="ssl tomcat"/><category term="static method"/><category term="subversion.javahl"/><category term="system.err"/><category term="thread basics"/><category term="thread life cycle"/><category term="threads java"/><category term="tomcat https"/><category term="tomcat keystore"/><category term="tomcat security"/><category term="tomcat ssl"/><category term="tuning jvm"/><category term="tuning jvm heap"/><category term="validation"/><category term="web.xml"/><title type='text'>Java-Espresso</title><subtitle type='html'>Through this blog, I share my experiences, Problems that me and my team faced and how we resolved them.&#xa;&#xa;Apart from that Technical tips, tricks, Java Basics and also questions that are asked in interviews related to Java.&#xa;&lt;br&gt;&#xa;&lt;b&gt;&lt;i&gt;Now blog can be accessed from a direct URL &lt;/i&gt;     &lt;a href=&quot;http://www.java-espresso.in/&quot;&gt;www.java-espresso.in&lt;/a&gt; &lt;/b&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>42</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-7726930805589692454</id><published>2013-10-15T03:02:00.000-07:00</published><updated>2013-10-15T03:10:31.332-07:00</updated><title type='text'>580 - Critical Mass UVA Online Judge</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=714&amp;amp;page=show_problem&amp;amp;problem=841&quot;&gt;http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;amp;Itemid=8&amp;amp;category=714&amp;amp;page=show_problem&amp;amp;problem=841&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;ctime&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;vector&amp;gt;
#include&amp;lt;cstdio&amp;gt;
#include&amp;lt;cstdlib&amp;gt;
#include&amp;lt;stack&amp;gt;
#include&amp;lt;queue&amp;gt;
#include&amp;lt;map&amp;gt;
#include&amp;lt;algorithm&amp;gt;
#include&amp;lt;sstream&amp;gt;
#include&amp;lt;cstring&amp;gt;
#define For(i,n) for(int i=0;(i)&amp;lt;n;i++)
#define mp make_pair
#define pb push_back
#define MOD 10000007
using namespace std;

int main(){

    int p[]={3,6};
    int *t=p;
    int x=*t++;
    cout&amp;lt;&amp;lt;*t&amp;lt;&amp;lt;x;
   long long  int dp[101][4];
    memset(dp,0,sizeof(dp));
    dp[1][0]=1;dp[1][1]=1;
    dp[2][0]=2;dp[2][1]=1;dp[2][2]=1;
    For(i,101){
        if(i&amp;lt;3)continue;
        For(j,3){
            dp[i][0]+=dp[i-1][j];
        }
        dp[i][1]=dp[i-1][0];
        dp[i][2]=dp[i-1][1];
        dp[i][3]=dp[i-1][2]+2*dp[i-1][3];

    }
    int n;
    cin&amp;gt;&amp;gt;n;
    while(n!=0){
        cout&amp;lt;&amp;lt;dp[n][3]&amp;lt;&amp;lt;endl;
        cin&amp;gt;&amp;gt;n;
    }
}

&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/7726930805589692454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2013/10/580-critical-mass-uva-online-judge.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/7726930805589692454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/7726930805589692454'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2013/10/580-critical-mass-uva-online-judge.html' title='580 - Critical Mass UVA Online Judge'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-7005763045221406462</id><published>2013-03-10T10:32:00.001-07:00</published><updated>2013-03-10T10:32:32.832-07:00</updated><title type='text'>Best Practices Common and Important Architecture for Web Application  Using Java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
An architecture is the most important part for any software. The whole software depends on the architecture, you follow initially. It is very difficult or almost impossible, to change the architecture of any software application which is already build. A good architecture is utmost requirement of good Quality Attribute.&lt;br /&gt;
&lt;br /&gt;
Today I will discuss the architecture for the web application. This architecture will help for new comers and also for others. This architecture is not only for Java based web application, but also for Web application built in PHP, dotnet , etc. I am here to design the general architecture. Generally if a good architecture is not followed, then at the end we try to fix issues according to our requirement and the application finally becomes too complex, to make changes. Please do read about Software Architecture&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Software_architecture&quot;&gt;http://en.wikipedia.org/wiki/Software_architecture&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This blog is for people who want to design good architecture in their web applications. This architecture is the layered architecture. There are different frameworks available in java like struts,spring,etc. The Struts and Spring are themselves following MVC patterns. So, if you are using these framework, almost you are half-way to good architecture. But if you are not using these frameworks, then you need good architecture. Following is the general architecture which I generally follow.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP0ajc1jeljKOD8lD63ctdY02vgZ26DHuEMxRNfDgZBLycBbmfHFY8by_fYyR8kx7Hw20Zy6MWa-wVi8MzvTM-FOTV4n15asoqDOLRFuWKSqX3haijW7tN0EOVVJeG5xK6KqNEpYTeN_Ql/s1600/architectureDiag.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP0ajc1jeljKOD8lD63ctdY02vgZ26DHuEMxRNfDgZBLycBbmfHFY8by_fYyR8kx7Hw20Zy6MWa-wVi8MzvTM-FOTV4n15asoqDOLRFuWKSqX3haijW7tN0EOVVJeG5xK6KqNEpYTeN_Ql/s400/architectureDiag.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now, the question is &quot;How can we implement them in any language&quot;. I will discuss this in terms of J2EE. In my next blog I will list some some of my classes for PHP which might be useful for all.&lt;br /&gt;
&lt;br /&gt;
Views are JSP&#39;s and Controllers are Sevlets. Every new request goes to the servlet. Servlet will interact to Service or Business layer and then it forward the request to the desired JSP(view). Following are some of the guidelines, which are preferred.&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Keep all the configurable parameters in the properties files. With properties file we can easily keep (key,value) pair.The simplest example is to keep SQL Connection properties in connection.properties file. The advantage of this approach is that, when we want &amp;nbsp;to change any value, in that case, we don&#39;t have to touch code, we can directly change in these files and also it can be easily maintained by non technical guys. These properties file are kept in a separate folder( this folder should be in classpath).&lt;/li&gt;
&lt;li&gt;Create Interfaces for each property file. As we know, interfaces variables are &quot;public static final&quot;. Now link each property (key) with a interface variable. The advantage of this approach is that you can directly use these variables, just by name of interfaces, irrespective of the fact that the value can change in near future. Also create a separate package for these interfaces.&lt;/li&gt;
&lt;li&gt;Create POJO&#39;s. These POJO&#39;s are generally called Transfer Objects. These Transfer Objects are used to pass values from one layer to another. Create a package for POJO&#39;s&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Create useful utilities. The utilities are the objects which are commonly used. For example make a class of Database utility. The Database utility contains methods like getConnection(), closeConnection(). So, if tomorrow you want to switch to a different database you can just change the getConnection() method, without affecting other layers. Create a separate package for utilities.&lt;/li&gt;
&lt;li&gt;Create separate package for controllers, exceptions(your own Exception handling), business logic&lt;/li&gt;
&lt;li&gt;In case of JSP&#39;s make a separate folder for css, images, java script. If possible try to use Apache tiles. The advantage of using tiles is that you can make your layout. The layout may contain a header and footer. So, if in future you want to change the layout, you have to change in your layout JSP&#39;s and whole layout of your web-application gets changed.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Following diagram show the package wise architecture diagram.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmgxAx9NFakbtzjYEtJ8qtVhUG0tqUdltm6MsfnZdC_NOoeg3FE7C3khAr_gWZywCf80VGCsAp1nrou9MthrfTXygYguODtRe2UPAWUZtC-wsUd4S35Bm5V1viEJ3s0hsKcU9ott_2VKsC/s1600/sampleArch.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmgxAx9NFakbtzjYEtJ8qtVhUG0tqUdltm6MsfnZdC_NOoeg3FE7C3khAr_gWZywCf80VGCsAp1nrou9MthrfTXygYguODtRe2UPAWUZtC-wsUd4S35Bm5V1viEJ3s0hsKcU9ott_2VKsC/s640/sampleArch.jpg&quot; width=&quot;365&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Following is the sample application.&lt;a href=&quot;https://docs.google.com/viewer?a=v&amp;amp;pid=sites&amp;amp;srcid=ZGVmYXVsdGRvbWFpbnx2aW5rbHN0dWZmfGd4OjNkYTk2MDllYWFhYTAxNjQ&quot;&gt;Click here to download sample architecture&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Please give your valuable feedback and also tell the ways to improve the architecture.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/7005763045221406462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2013/03/best-practices-common-and-important.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/7005763045221406462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/7005763045221406462'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2013/03/best-practices-common-and-important.html' title='Best Practices Common and Important Architecture for Web Application  Using Java'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP0ajc1jeljKOD8lD63ctdY02vgZ26DHuEMxRNfDgZBLycBbmfHFY8by_fYyR8kx7Hw20Zy6MWa-wVi8MzvTM-FOTV4n15asoqDOLRFuWKSqX3haijW7tN0EOVVJeG5xK6KqNEpYTeN_Ql/s72-c/architectureDiag.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-6750986845333400154</id><published>2012-10-23T03:02:00.000-07:00</published><updated>2012-10-23T03:02:00.854-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><category scheme="http://www.blogger.com/atom/ns#" term="maven cusotm jar repository"/><category scheme="http://www.blogger.com/atom/ns#" term="maven repository"/><title type='text'>How to include custom jar into your Maven repository?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Still you will find jars which are not there in Maven repository. Classic example is suppose you create a common utility jar and you want to use it across projects or it could be a third party jar which has private licence and so cannot be there in Maven central repository.
In above cases, you can actually put the required jar easily in the Maven local repository. For demonstration purpose, we are using Kaptcha. 
&lt;br /&gt;Here is the command:
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;
mvn install:install-file 
-Dfile=c:\kaptcha-2.3.2.jar 
-DgroupId=com.google 
-DartifactId=kaptcha 
-Dversion=2.3.2 
-Dpackaging=jar
&lt;/pre&gt;
&lt;br /&gt;
Remember to remove the newlines from above command incase you are copying and pasting.&lt;br /&gt;
Below is the result from command line after executing the command:
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;
C:\&gt;mvn install:install-file -Dfile=&quot;c:\kaptcha-2.3.2.jar&quot; -DgroupId=com.google
-DartifactId=kaptcha -Dversion=2.3.2 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-po
m ---
[INFO] Installing c:\kaptcha-2.3.2.jar to C:\Users\dharmvir.singh\.m2\repository
\com\google\kaptcha\2.3.2\kaptcha-2.3.2.jar
[INFO] Installing C:\Users\DHARMV~1.SIN\AppData\Local\Temp\mvninstall71581647865
23828175.pom to C:\Users\dharmvir.singh\.m2\repository\com\google\kaptcha\2.3.2\
kaptcha-2.3.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.587s
[INFO] Finished at: Tue Oct 23 15:23:57 IST 2012
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
&lt;/pre&gt;

Job is done. You can now specify the dependency of this jar as shown:

&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;
&lt;dependency&gt;
      &lt;groupId&gt;com.google&lt;/groupId&gt;
      &lt;artifactId&gt;kaptcha&lt;/artifactId&gt;
      &lt;version&gt;2.3.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;/pre&gt;

&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/6750986845333400154/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/10/how-to-include-custom-jar-into-your.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/6750986845333400154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/6750986845333400154'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/10/how-to-include-custom-jar-into-your.html' title='How to include custom jar into your Maven repository?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total><georss:featurename>Bangalore, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.724026199999999 77.2787057 13.2191712 77.910419699999991</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-8780337554368896370</id><published>2012-10-15T01:20:00.000-07:00</published><updated>2012-10-15T01:20:37.905-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><category scheme="http://www.blogger.com/atom/ns#" term="maven eclipse proxy setting"/><category scheme="http://www.blogger.com/atom/ns#" term="maven proxy config"/><category scheme="http://www.blogger.com/atom/ns#" term="maven proxy setting"/><category scheme="http://www.blogger.com/atom/ns#" term="maven proxy setting not working"/><title type='text'>Configuring Maven inside proxy network</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
   Maven version I used is 3.0.4 and environment is windows 7 enterprise edition.  

 &lt;div&gt; &lt;br /&gt;&lt;/div&gt;  
Well, it is pretty simple, &lt;div&gt; &lt;br /&gt;&lt;/div&gt;
 
collect your proxy server and port configuration and if username and password  
&amp;nbsp;are there then them too and save them in your settings.xml.&lt;/div&gt;
 
Settings.xml can be found either in &amp;lt;userhome&amp;gt;/.m2/settings.xml (Apache documentation tells about this path but I couldn&#39;t find it in this location, link to proxy config doc.. &lt;a href=&quot;http://maven.apache.org/guides/mini/guide-proxies.html&quot; target=&quot;_blank&quot;&gt;proxy config mini guide&lt;/a&gt;) or (I found them in this path &amp;lt;maven unzipped directory&amp;gt;/config/settings.xml, in my case path was D:/apache-maven-3.0.4/config/settings.xml)
&lt;/div&gt;

Now, you have to uncomment this section from settings.xml and save the correct info here as shown:
&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;
 &lt;proxies&gt;
    &lt;!-- proxy
     | Specification for one proxy, to be used in connecting to the network. 
     |--&gt;
    &lt;proxy&gt;
      &lt;id&gt;optional&lt;/id&gt;
      &lt;active&gt;true&lt;/active&gt;
      &lt;protocol&gt;http&lt;/protocol&gt;
      &lt;username&gt;proxyuser&lt;/username&gt;
      &lt;password&gt;proxypass&lt;/password&gt;
      &lt;host&gt;Your Proxy server IP Here&lt;/host&gt;
      &lt;port&gt;Your proxy server port numbere here&lt;/port&gt;
      &lt;nonProxyHosts&gt;local.net|some.host.com&lt;/nonProxyHosts&gt;
    &lt;/proxy&gt;
    
  &lt;/proxies&gt;
&lt;/pre&gt;


&lt;h3&gt;Related Articles&lt;/h3&gt;
&lt;a href=&quot;http://java-espresso.blogspot.in/2011/09/orgtigrissubversionjavahlclientexceptio.html&quot; target=&quot;_blank&quot;&gt; Eclipse proxy setting &lt;/a&gt;
</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/8780337554368896370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/10/configuring-maven-inside-proxy-network.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8780337554368896370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8780337554368896370'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/10/configuring-maven-inside-proxy-network.html' title='Configuring Maven inside proxy network'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-2853098633349407953</id><published>2012-06-28T10:54:00.002-07:00</published><updated>2012-06-28T11:09:26.095-07:00</updated><title type='text'>5.JAVA BASICS..CONCEPT OF STATIC</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Here you will learn about the static keyword which in itself a very useful concept.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What do you understand by static?&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; By seeing the word static three things come to our mind&lt;br /&gt;
&amp;nbsp;1) Class Global variable- It means that it is global to the class. No object copy.&lt;br /&gt;
&amp;nbsp;2) One copy in memory - Only one copy exists in memory.&lt;br /&gt;
&amp;nbsp;3) It exists in memory even before creation of objects.&lt;br /&gt;
&lt;br /&gt;
We will take some examples of objects and their memory allocation.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;class Test
{
int a;
float b;
int d=10;
}

class TestMain
{
public static void main(String[] args)
{
Test obj1=new Test();
Test obj2=new Test();
Test obj3=new Test();
obj3.d=15;
obj3.b=5.0;
obj2.a=5;
obj3=new Test(); &amp;nbsp; &amp;nbsp; &amp;nbsp; //Line 7
obj3.d=16;
}
}
&lt;/pre&gt;Following is the heap diagram with objects.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbdiYfjcH4JfGU-wRgL-POhwLXD-6S6Odik0nMb51RXp-UzeYvzAmwsU5Xn642Gqy2I_97cHz8UlPin78LQg-eWLk6mC2S7GOQiV__YhC4LC-yK8w5gfOEvU_V4O8tfdQNjRF-UjxoVsSq/s1600/Instance.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbdiYfjcH4JfGU-wRgL-POhwLXD-6S6Odik0nMb51RXp-UzeYvzAmwsU5Xn642Gqy2I_97cHz8UlPin78LQg-eWLk6mC2S7GOQiV__YhC4LC-yK8w5gfOEvU_V4O8tfdQNjRF-UjxoVsSq/s400/Instance.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;In the above figure you will find that all the objects are created in the heap memory. obj1,obj2,obj3 are the references which points to these objects. The references obj1,obj2,obj3 are defined inside the method, we can say that these references are using stack memory. In the above objects,you will also &amp;nbsp;find that all the objects have their own copy of variables. Each object have different value of variables. In short all objects have their own variables.&lt;br /&gt;
Obj3 firstly refers to other object and after line-7 it points to different object.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example of static:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;class Test
{
int a;
float b;
static int c
int d=10;
}

class TestMain
{
public static void main(String[] args)
{
Test obj1=new Test();
Test obj2=new Test();
Test obj3=new Test();
obj3.d=15;
obj3.b=5.0;
obj2.a=5;
obj3=new Test(); &amp;nbsp; &amp;nbsp; &amp;nbsp; //Line 7
obj3.d=16
obj1.c=6;
obj3.c=10;
obj2.c=15;
Test.c=20;
}
}
&lt;/pre&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip10VKAFQqbmliy1F0lPOR5sDHVLW08s02f_ZA_3t1aRrbnMtGPt0yhmGEinQhklZlJERkuv38H2Mtv9imrKQK1RSY7YXejJ4o7ekeAOdAHCwEO-T_RXDHprMjb-SIjC_V7JuBR12fn1E1/s1600/Instance.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip10VKAFQqbmliy1F0lPOR5sDHVLW08s02f_ZA_3t1aRrbnMtGPt0yhmGEinQhklZlJERkuv38H2Mtv9imrKQK1RSY7YXejJ4o7ekeAOdAHCwEO-T_RXDHprMjb-SIjC_V7JuBR12fn1E1/s400/Instance.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
In the above example &#39;c&#39; is the static variable,so there exists only one copy of variable c and is not inside any of the object area,instead it has a separate memory space which is&amp;nbsp;accessible by any of the objects and even by the class. This is how the static works.&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;b&gt;static in broader terms:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
Following are the different ways of using keyword static&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;Methods&lt;/li&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Block&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Variables:&lt;/b&gt;&lt;br /&gt;
A static variable have one copy and any instance can change its value.&lt;br /&gt;
Use of Static variables: Whenever you fell a resource should be accessible by all the instances and you need only one copy. Take a simple example of a basket of chocolates, take &#39;N&#39; students who can take chocolate from this basket.Student will act as an object. When a student takes a chocolate from basket then the number of chocolates decreases. In these types of examples, take count_of_chocolate as a static variable and when an object takes it the count of chocolate decreases.&lt;br /&gt;
&lt;br /&gt;
Static variables exist in memory even before the instances are created. By this statement don&#39;t misunderstand that it will always exist in memory. It will only exist in memory when a class gets loaded( you will learn class loading later).&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Difference between static variables and normal variables&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;static variables- Class global&lt;br /&gt;
normal variables- Object specific&lt;/li&gt;
&lt;li&gt; static variables- Only one copy &lt;br /&gt;
normal variables- copies are equal to the number of objects that exist in memory&lt;/li&gt;
&lt;li&gt; static variables- Exist when class gets loaded&lt;br /&gt;
normal variables- Exist when instance get created, each object has different copy&lt;/li&gt;
&lt;li&gt; static variables- Every object have access to this variable,also accessed by class name &lt;br /&gt;
normal variables- Object able to access its own copy.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Static methods:&lt;/b&gt;&lt;/div&gt;Prefixing static before a method name makes a method static.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Where the normal methods exist in memory?&lt;/span&gt;&lt;br /&gt;
There is only &lt;i&gt;one copy of normal methods&lt;/i&gt;,it does not depend on the number of objects. The methods are stored in &lt;i&gt;Method area&lt;/i&gt;. Method area is a separate memory in Heap which stores the class methods.Methods are executed from this area.&lt;br /&gt;
Static Methods- They are also stored in the same area and only one copy exist in memory.&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Difference between static method and normal method&lt;/span&gt;&lt;br /&gt;
Both have one copy in memory. Static method exist in memory even when there is no object while the normal method exist only after instance is created.&lt;br /&gt;
&lt;i&gt;Can static method access non static variable???&lt;/i&gt;..&lt;br /&gt;
No. Static method and variable exist in memory when a class gets loaded while the non static variable and method exist only after instance is created. This is the reason why static method cannot access non static variable.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Static Classes:&lt;/b&gt;&lt;br /&gt;
Remember an outer class can never be static as there is no point in declaring an outer class an static class. Only the nested classes are allowed to be static. Technically, inner classes are not called static, inner classes are local and anonymous classes. Static classes are same as normal classes, the only difference is that static classes cannot access not static member variables and methods of the parent class.&lt;br /&gt;
Static class behaves like normal classes.&lt;br /&gt;
&lt;i&gt;&amp;nbsp; Nested Classes: Nested classes are of 2 types&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; a) static nested classes&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; b) Non-static Nested Classes- These classes are called Inner Class.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
To know more about Inner and nested class please read&amp;nbsp;&lt;a href=&quot;http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html&quot;&gt;http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Static Blocks:&lt;/b&gt;&lt;br /&gt;
A class can have number of static block and normal block.&lt;br /&gt;
All normal block will be executed each time a instance is created in the order they are exist in class and are executed before the constructor is called while the static block is executed only once on class loading (it&#39;s execution does not depend on the number of instance). As the static block is executed on class loading, it is executed before normal blocks gets executed.&lt;br /&gt;
&lt;br /&gt;
Here is a simple example to understand the difference between static and normal block&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;public class StaticBlockExp {

 static{
  System.out.println(&quot;1.static block&quot;);
 }
 static{
  System.out.println(&quot;2.static block&quot;);
 }
 {
  System.out.println(&quot;Welcome to Java&quot;);
 }
 {
  System.out.println(&quot;Welcome to world of java&quot;);
 }
 public StaticBlockExp()
 {
  System.out.println(&quot;Constructor&quot;);
 }
 public static void main(String[] args) {
  new StaticBlockExp();
  new StaticBlockExp();
 }
}
&lt;/pre&gt;&lt;br /&gt;
&lt;i&gt;Output of above program:&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;1.static block&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;2.static block&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Welcome to Java&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Welcome to world of java&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Constructor&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Welcome to Java&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Welcome to world of java&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Constructor&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
From this it is clear that static blocks are executed only once while normal blocks are executed each time an instance is created.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/2853098633349407953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/06/5java-basicsconcept-of-static.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/2853098633349407953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/2853098633349407953'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/06/5java-basicsconcept-of-static.html' title='5.JAVA BASICS..CONCEPT OF STATIC'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbdiYfjcH4JfGU-wRgL-POhwLXD-6S6Odik0nMb51RXp-UzeYvzAmwsU5Xn642Gqy2I_97cHz8UlPin78LQg-eWLk6mC2S7GOQiV__YhC4LC-yK8w5gfOEvU_V4O8tfdQNjRF-UjxoVsSq/s72-c/Instance.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-5588951914577495217</id><published>2012-06-21T00:02:00.000-07:00</published><updated>2012-06-21T00:06:02.290-07:00</updated><title type='text'>Spring 3.2 M1 released...</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;b&gt;Spring 3.2 comes with a lot of new stuff. Below is a brief listing of the features that are in 3.2 version:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;I&lt;/span&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;nitial support for&amp;nbsp;&lt;/span&gt;asynchronous @Controller methods
&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;Early&amp;nbsp;&lt;/span&gt;support for JCache-based cache providers
&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;Significant&amp;nbsp;&lt;/span&gt;performance improvements&lt;span style=&quot;line-height: 18px;&quot;&gt;&amp;nbsp;in autowiring of non-singleton beans&lt;/span&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif; line-height: 18px;&quot;&gt;&lt;b&gt;Initial delay&amp;nbsp;support for&amp;nbsp;@Scheduled&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif; line-height: 18px;&quot;&gt;&lt;b&gt;Ability to&amp;nbsp;choose between multiple executuors with @Async
&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif; line-height: 18px;&quot;&gt;&lt;b&gt;Enhanced&amp;nbsp;bean profile selection using the not (!) operator
&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif; line-height: 18px;&quot;&gt;&lt;b&gt;&lt;a href=&quot;https://jira.springsource.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+SPR+AND+fixVersion+%3D+&#39;3.2+M1&#39;+and+type+%3D+Bug+order+by+votes+desc&quot; rel=&quot;nofollow&quot; style=&quot;text-decoration: none;&quot; target=&quot;_blank&quot;&gt;47 bugs&lt;/a&gt;&amp;nbsp;fixed,&amp;nbsp;&lt;a href=&quot;https://jira.springsource.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+SPR+AND+fixVersion+%3D+&#39;3.2+M1&#39;+and+type+%3D+&#39;New+Feature&#39;+order+by+votes+desc&quot; rel=&quot;nofollow&quot; style=&quot;text-decoration: none;&quot; target=&quot;_blank&quot;&gt;8 new features&lt;/a&gt;&amp;nbsp;and&amp;nbsp;36 improvements&amp;nbsp;implemented
&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: #38761d; font-family: Times, &#39;Times New Roman&#39;, serif; line-height: 18px;&quot;&gt;&lt;b&gt;There are a lot of other stuff.. checkout Spring source website ...&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/5588951914577495217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/06/spring-32-m1-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5588951914577495217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5588951914577495217'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/06/spring-32-m1-released.html' title='Spring 3.2 M1 released...'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-34255540480350380</id><published>2012-06-12T02:52:00.000-07:00</published><updated>2012-06-12T02:52:09.599-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="java System"/><category scheme="http://www.blogger.com/atom/ns#" term="java system println"/><category scheme="http://www.blogger.com/atom/ns#" term="java system println format"/><category scheme="http://www.blogger.com/atom/ns#" term="java system.println example"/><category scheme="http://www.blogger.com/atom/ns#" term="java.lang.system"/><category scheme="http://www.blogger.com/atom/ns#" term="system.err"/><category scheme="http://www.blogger.com/atom/ns#" term="System.out"/><category scheme="http://www.blogger.com/atom/ns#" term="System.out.println"/><title type='text'>System.out.println(), What is it?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
System is a class in java.lang package. It is a system related class and most of times make native calls.
As far as out is concerned. System class declares it something like this:
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;
  public final static InputStream in = null; 
  public final static PrintStream out = null; 
  public final static PrintStream err = null; 
&lt;/pre&gt;

  As shown above both err and out are instances of PrintStream class (java.io.PrintStream). System class has setters for all the three mentioned above but no getters. InputStream is again from java.io package.
Setters are written something like as shown:
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;
  public static void setOut(PrintStream out) { 
    checkIO(); 
    setOut0(out); 
 }
&lt;/pre&gt;

Summarizing above, System is class in java.lang package and out is the instance of PrintStream class from java.io package and println() is a method from the PrintStream class obviously.
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/34255540480350380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/06/systemoutprintln-what-is-it.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/34255540480350380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/34255540480350380'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/06/systemoutprintln-what-is-it.html' title='System.out.println(), What is it?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total><georss:featurename>Bangalore, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.724026199999999 77.2787057 13.2191712 77.910419699999991</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-268620772688230877</id><published>2012-05-18T01:18:00.000-07:00</published><updated>2012-05-18T01:21:37.854-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAXB"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxb data format"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxb data type mapping"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxb data types"/><category scheme="http://www.blogger.com/atom/ns#" term="JAXB datatype"/><category scheme="http://www.blogger.com/atom/ns#" term="JAXB datatype maping"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxb date"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxb date format"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxb mapping"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxb mapping list"/><title type='text'>JAXB: XSD datatypes mapping to Java DataTypes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Below is the list of mappings from XSD data types to Java data types
&lt;table border=&quot;1px solid&quot; width=&quot;90%&quot; padding=&quot;5px&quot;&gt;
 &lt;tr&gt;
  &lt;th style=&quot;text-align:center&quot;&gt;XSD types&lt;/th&gt;&lt;th style=&quot;text-align:center&quot;&gt; Java DataTypes&lt;/th&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;byte&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;byte&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;int&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;int&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;integer&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.math.BigInteger&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;decimal&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.math.BigDecimal&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;long&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;long&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;float&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;float&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;double&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;double&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;duration&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.Duration&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;date&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;dateTime&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;string&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.lang.String&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;nonNegativeInteger&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.math.BigInteger&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;nonPositiveInteger&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.math.BigInteger&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;unsignedByte&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;short&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;unsignedInt&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;long&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;unsignedLong&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.math.BigInteger&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;unsignedShort&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;int&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;anyURI&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.lang.String&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;base64Binary&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;byte [] (byte array)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;boolean&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;boolean&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;ENTITIES&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;List&lt;String&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;ENTITY&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;java.lang.String&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;time&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;gDay&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;gMonth&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;gYear&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;gMonthDay&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt; javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td style=&quot;text-align:center&quot;&gt;gYearMonth&lt;/td&gt;&lt;td style=&quot;text-align:center&quot;&gt;javax.xml.datatype.XMLGregorianCalendar&lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;

Whatever data types are not there in Java JAXB has created appropriate datatypes in their API, for example, XMLGregorainCalendar. Now the question is how to convert it our facourite dataypes like java.util.Date or java.sql.Date or java.util.Calendar etc. You can probably write an Adaptor class which has static methods to do all these conversion.
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/268620772688230877/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/05/jaxb-xsd-datatypes-mapping-to-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/268620772688230877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/268620772688230877'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/05/jaxb-xsd-datatypes-mapping-to-java.html' title='JAXB: XSD datatypes mapping to Java DataTypes'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.724026199999999 77.2787057 13.2191712 77.910419699999991</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-60514034186365434</id><published>2012-05-03T03:37:00.001-07:00</published><updated>2012-05-03T03:37:33.368-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="java static factory method"/><category scheme="http://www.blogger.com/atom/ns#" term="java static factory method example"/><category scheme="http://www.blogger.com/atom/ns#" term="java static factory method vs constructor"/><category scheme="http://www.blogger.com/atom/ns#" term="java static method"/><category scheme="http://www.blogger.com/atom/ns#" term="static method"/><title type='text'>Why to prefer static factory methods over constructors to get the object of a class?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Instead of creating objects using new operator you can also use static method to instantiate a class.
Code listing:
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;
// instantiating a class using constructor
Dog dog = new Dog(); 
..........................................

// instantiating the class using static method
Class Dog{
  private Dog(){
  }
  // factory method to instantiate the class
  public static Dog getInstance(){
    return new Dog();
  }
}
&lt;/pre&gt;

Using static factory methods have both advantages as well as disadvantages.
Advantages:
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Static factory methods can have different name than class whereas constructors cannot: &lt;/b&gt; As methods have names, they convey their purpose clearly as opposed to constructors. A class can have only one constructor with a given signature, developers get around this restriction by changing the order of parameters passed to constructors; In case of methods you can give a different name to resolve the issue.
&lt;/li&gt;
&lt;li&gt; &lt;b&gt;Static methods support conditional instantiation: &lt;/b&gt; Each time you invoke a constructor an object will get created but you might not want that. (for example, in singleton class you will maintain a single object). Or suppose you want to check some condition only then you want to create a new object.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt; Methods can return subtypes of return type:&lt;/b&gt; Suppose there is a class Animal and it has subclass Dog. We have static method with signature 
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;
  public static Animal getInstance(){
   ...
  }
}
&lt;/pre&gt;
then method can return Both objects of type Animal and Dog which provides great flexibility.
&lt;/li&gt;
&lt;/ol&gt;

Disadvantages:
&lt;ol&gt;
&lt;li&gt;
&lt;b&gt;If constructor of the class is not public or protected then the class cannot be sub classed:&lt;/b&gt; If you ask if there is a workaround to this, there is not. But honestly, it is better as you cannot use inheritance and so you have to use composition which is always better than inheritance any day.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Another disadvantage is you cannot differentiate between static factory methods and regular factory methods:&lt;/b&gt; There is no syntactical difference but if you follow some naming convention then it is easy to identify. For example, &lt;i&gt;getInstance()&lt;/i&gt; is used in many frameworks to provide the instance of a class (java.util.Calendar, ).
&lt;/li&gt;
&lt;/ol&gt;
Examples of static factory methods in Java:
&lt;ol&gt;
&lt;li&gt;Pattern.compile&lt;/li&gt;
&lt;li&gt;Calendar.getInstance&lt;/li&gt;
&lt;li&gt;Collections.synchronizeCollection&lt;/li&gt;
&lt;/ol&gt;
List is very big.

&lt;b&gt;References&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;Effective Java 2nd edition by Joshua Bloch&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.javapractices.com/topic/TopicAction.do?Id=21&quot;&gt;Factory Methods&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/60514034186365434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/05/why-to-prefer-static-factory-methods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/60514034186365434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/60514034186365434'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/05/why-to-prefer-static-factory-methods.html' title='Why to prefer static factory methods over constructors to get the object of a class?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.724026199999999 77.2787057 13.2191712 77.910419699999991</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-6796653469064235448</id><published>2012-02-20T03:21:00.000-08:00</published><updated>2012-02-20T03:21:56.718-08:00</updated><title type='text'>JAR to JAVA converter</title><content type='html'>I went through many websites,but i did not find any converter for jar file to .java files at one go.&lt;br /&gt;
So, I thought of writing a script for this conversion. This script also keeps the package structure same as in the jar file&lt;br /&gt;
&lt;br /&gt;
Following are the prerequisites&lt;br /&gt;
&lt;ul&gt;&lt;li&gt; This is restricted to windows platform &lt;/li&gt;
&lt;li&gt; Unzip utility should be installed in the system&lt;/li&gt;
&lt;li&gt; jad decompiler should be installed.&lt;br /&gt;
If you don&#39;t have jad installed, you can find from the following link&lt;br /&gt;
&lt;a href=&quot;http://www.varaneckas.com/sites/default/files/jad/jad158g.win.zip&quot;&gt;click here to download&lt;/a&gt;  &lt;/li&gt;
&lt;li&gt;Unzip the jad.zip downlaoded in step2,set the jad.exe in the systems path variable. &lt;/li&gt;
&lt;li&gt;Run the command prompt in the administrator mode  &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Steps to run the batch file&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;cd &quot;&lt;i&gt;path to which batch file is placed&lt;/i&gt;&quot; &lt;/li&gt;
&lt;li&gt;jar2java.bat &quot;&lt;i&gt;jar file name/jar file path with jar file name&lt;/i&gt;&quot; &lt;/li&gt;
&lt;b&gt;Note: Give jar file name without extension&lt;/b&gt;
&lt;/ul&gt;Download the batch file from &lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/jar2java.bat.txt&quot;&gt;here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:Remove the extention .txt to make it .bat file.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example:&lt;/b&gt;&lt;br /&gt;
Step 1) &gt;cd D:\jartojava (Copy the above downloaded batch file in this folder)&lt;br /&gt;
Step 2) jartojava&gt; jar2java.bat abc (copy abc.jar in this folder)&lt;br /&gt;
Here a folder named abc is created with all the java files found in abc.jar.</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/6796653469064235448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2012/02/jar-to-java-converter.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/6796653469064235448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/6796653469064235448'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2012/02/jar-to-java-converter.html' title='JAR to JAVA converter'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-5523367971041318113</id><published>2011-12-16T01:51:00.000-08:00</published><updated>2011-12-16T01:58:20.653-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="deployment descriptor"/><category scheme="http://www.blogger.com/atom/ns#" term="Difference between ServletConfig and ServletContext"/><category scheme="http://www.blogger.com/atom/ns#" term="difference servletconfig servletcontext"/><category scheme="http://www.blogger.com/atom/ns#" term="diffrence ServletContext ServletConfig"/><category scheme="http://www.blogger.com/atom/ns#" term="ServletConfig"/><category scheme="http://www.blogger.com/atom/ns#" term="ServletContext"/><category scheme="http://www.blogger.com/atom/ns#" term="web.xml"/><title type='text'>Difference between ServletConfig and ServletContext</title><content type='html'>Following table lists down the main differences and others things are discussed afterwords:&lt;br /&gt;
&lt;table border=&quot;1&quot; width=&quot;100%&quot;&gt;&lt;tr&gt; &lt;th&gt;&lt;u&gt;ServletConfig&lt;/u&gt;&lt;/th&gt;&lt;th&gt;&lt;u&gt;ServletContext(It should have been ApplicationContext)&lt;/u&gt;&lt;/th&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;One ServletConfig object is created &lt;b&gt;per servlet&lt;/b&gt;&lt;/td&gt; &lt;td&gt;One ServletContext object is created &lt;b&gt;per Application&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Can be used to pass deployment time information to the Servlet. Information is stored as parameters in the deployment descriptor(web.xml)&lt;/td&gt; &lt;td&gt;Can be used to share Application level information across servlets and is this information is also stored in the web.xml as well as parameters (So it kind of acts as GlobalContext or Application Context)&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;Provides a set of methods to set and get the initialization configuration information&lt;/td&gt; &lt;td&gt;Provides a set of methods to the servlet so that servlet can communicate with the Container&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td align=&quot;center&quot;&gt;------------------------&lt;/td&gt;&lt;td&gt;Servlet can access a ServletContext object only through ServletConfig object&lt;/td&gt; &lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
&lt;h3&gt;Working with ServletConfig:&lt;/h3&gt;We will explaing here how to declare the Servlet init Parameters in in the Deployment Descriptor(web.xml) and how to retrieve them in the servlet also how to get the object of Servlet Context from ServletConfig.&lt;br /&gt;
web.xml: Declaring init parameters for a specific servlet&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;&lt;servlet&gt;
    &lt;description&gt;&lt;/description&gt;
    &lt;display-name&gt;SampleServ&lt;/display-name&gt;
    &lt;servlet-name&gt;SampleServ&lt;/servlet-name&gt;
    &lt;servlet-class&gt;in.javaespresso.web.SampleServ&lt;/servlet-class&gt;
    &lt;init-param&gt;
     &lt;description&gt;Sample Init Parameters&lt;/description&gt;
     &lt;param-name&gt;servParam&lt;/param-name&gt;&lt;param-value&gt;servValue&lt;/param-value&gt;&lt;/init-param&gt;
  &lt;/servlet&gt;
&lt;/pre&gt;Servlet Code: Getting init parameters inside the servlet&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;getServletConfig().getInitParameter(&quot;servParam&quot;);
&lt;/pre&gt;Servlet Code: Getting ServletContext object using ServletConfig&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;ServletContext context = getServletConfig().getServletContext();
&lt;/pre&gt;&lt;h3&gt;Working with ServletContext:&lt;/h3&gt;Let us get the context paramteres declared in the web.xml in the servlet and jsp&lt;br /&gt;
web.xml: Declaring context parameters&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;&lt;context-param&gt;
    &lt;description&gt;Sample context parameters&lt;/description&gt;
    &lt;param-name&gt;email&lt;/param-name&gt;&lt;param-value&gt;java.espresso@gmail.com&lt;/param-value&gt;&lt;/context-param&gt;
&lt;/pre&gt;Servlet Code: Accessing context params in Servlet&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;getServletContext().getInitParameter(&quot;email&quot;)
&lt;/pre&gt;JSP code: Accessing context params in JSP&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;&lt;%
getServletContext().getInitParameter(&quot;email&quot;);
%&gt;
&lt;/pre&gt;&lt;br /&gt;
Please find the code for the article attached &lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/ParamsKnow.zip&quot;&gt;here&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/5523367971041318113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/12/difference-between-servletconfig-and.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5523367971041318113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5523367971041318113'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/12/difference-between-servletconfig-and.html' title='Difference between ServletConfig and ServletContext'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-2926796475234520221</id><published>2011-11-14T05:10:00.000-08:00</published><updated>2011-11-14T19:08:51.956-08:00</updated><title type='text'>Remote Method Invocation(RMI) Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Here, we will learn basics of RMI and will implement a small example&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Remote Method Invocation Basics&lt;/b&gt;&lt;br /&gt;
As the name suggests,it is a system to call remote method,which may be on other JVM or other computer. It is built on top of Sockets. But,you don&#39;t have to deal with sockets and protocols directly. You can directly call a method on some other machine and it works,as if you have called it locally. To achieve this it passes the objects over the network(objects should be&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: &#39;Courier New&#39;, Courier, mono; font-size: x-small;&quot;&gt;Serializable&lt;/span&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Drawback:&lt;/i&gt;&amp;nbsp;RMI can only be used in java. Interaction with other language platform is not possible.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Requirements of RMI&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;Client Requirement&lt;/i&gt;&lt;br /&gt;
Let us suppose there is a server Object which is registered.&lt;br /&gt;
* Client Object have to find the Server Object(by looking it up in registry)&lt;br /&gt;
* Serialize the parameters and send&lt;br /&gt;
* Deserialize the response from the server&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Server Requirement&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;* &lt;/i&gt;Server should be a remote object&lt;br /&gt;
* The remote object should be registered(rmiregistry is used for registration)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;HelloInterface.java&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;import java.rmi.Remote;
import java.rmi.RemoteException;

public interface HelloInterface extends Remote {
 public String sayHello() throws RemoteException;
 }
&lt;/pre&gt;&lt;br /&gt;
&lt;i&gt;Hello.java&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;import java.rmi.RemoteException;
public class Hello implements HelloInterface 
{

private String message; 
public Hello (String msg) throws RemoteException {
message = msg;
 }
public String sayHello() throws RemoteException {
 return message;  
 }
}
&lt;/pre&gt;&lt;i&gt;HelloServer.java&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;import java.net.MalformedURLException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

class HelloServer {

 public static void main(String[] argv)  throws RemoteException, MalformedURLException {
  
  try{
   Hello remoteObj=new Hello(&quot;This is test RMI&quot;);
    Remote obj = UnicastRemoteObject.exportObject(remoteObj, 9502);
          Registry r = LocateRegistry.createRegistry(9502);
          r.bind(&quot;RemoteHelloServer&quot;, obj);
   System.out.println(&quot;Hello Server is ready.&quot;);
  }
  catch(Exception e)
  {
   e.printStackTrace();
  }
  
 }
}
&lt;/pre&gt;&lt;br /&gt;
&lt;i&gt;Steps for compilation:&lt;/i&gt;&lt;br /&gt;
1)javac HelloInterface.java&lt;br /&gt;
2)javac Hello.java&lt;br /&gt;
3)javac HelloWorld.java&lt;br /&gt;
4)rmiregistry     //In a separate command prompt&lt;br /&gt;
5)rmic -vcompat Hello           //will generate Hello_Stub.class and Hello_Skel.class&lt;br /&gt;
6)java HelloWorld&lt;br /&gt;
&lt;br /&gt;
After step 6,Server is up&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Steps for client code:&lt;/i&gt;&lt;br /&gt;
* Copy the HelloInterface.java and Hello_Stub.class file in client area&lt;br /&gt;
* Write a client program HelloClient.java, which looks up in registry. &lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;HelloClient.java&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

class HelloClient {
 public static void main(String[] args) {
  try {
   Registry registry;
  HelloInterface hello;
  registry=LocateRegistry.getRegistry(
                &quot;localhost&quot;,(new Integer(9502)).intValue());
  String name = &quot;RemoteHelloServer&quot;;
  
   hello = (HelloInterface) registry.lookup(name);
   System.out.println(hello.say());
  } catch (Exception e) {
   System.out.println(&quot;HelloClient exception: &quot; + e);
  }
 }
}
&lt;/pre&gt;&lt;br /&gt;
Compile and run the client code.&lt;br /&gt;
After this it is easy to expose your methods with RMI.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/2926796475234520221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/11/remote-method-invocationrmi-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/2926796475234520221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/2926796475234520221'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/11/remote-method-invocationrmi-example.html' title='Remote Method Invocation(RMI) Example'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-3670029070273115170</id><published>2011-10-31T04:06:00.000-07:00</published><updated>2011-10-31T04:06:19.562-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Base 64"/><category scheme="http://www.blogger.com/atom/ns#" term="Base 64 Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Base64"/><category scheme="http://www.blogger.com/atom/ns#" term="Base64 encoding"/><category scheme="http://www.blogger.com/atom/ns#" term="Base64 Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Base 64"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Base64"/><category scheme="http://www.blogger.com/atom/ns#" term="Java Base64 decoding"/><category scheme="http://www.blogger.com/atom/ns#" term="java base64 encode example"/><title type='text'>Base64 encoding and decoding in Java</title><content type='html'>&lt;b&gt;What is Base 64 Encoding Scheme?&lt;/b&gt;&lt;br /&gt;
Wiki says -&lt;br /&gt;
&quot;Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The Base64 term originates from a specific MIME content transfer encoding.&quot;&lt;br /&gt;
&lt;br /&gt;
In simple terms Base64 encoding is a Binary to ASCII text conversion technique. Other such techniques available are &lt;a href=&quot;http://en.wikipedia.org/wiki/Quoted-printable&quot; target=&quot;_blank&quot;&gt;quoted-printable&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Hexadecimal&quot; target=&quot;_blank&quot;&gt;hexadecimal&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/BinHex&quot; target=&quot;_blank&quot;&gt;BinHex&lt;/a&gt;, etc.&lt;br /&gt;
&lt;br /&gt;
Binary to text encoding/decoding techniques are used when there is doubt that the transmission protocol/channel might not be capable of handling the non-textual data, best examples are email sent via MIME, Usenet. For example, many browser normally convert a space in URLs to %20D or such like characters and you might be in trouble if your server doesn&#39;t reconvert them but you can&#39;t possible crack down every such possible case. So better is use an encoding scheme that converts your data to text based characters.&lt;br /&gt;
&lt;br /&gt;
your data =&gt; [ Base64 Encoding System ] =&gt; Textual Data&lt;br /&gt;
Image     &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&gt; [ Base64 Encoding System ] =&gt; Image converted to text data&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Is Base64 Encoding scheme a Encryption technique?&lt;/b&gt; NO, don&#39;t even think like an idiot. it is simply converting data from one form to another so that no modification happens due to the limitation in my transmission protocol/channel but there is not concept of cryptography involved at all.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How Base64Encoding works?&lt;/b&gt; Well, look at &lt;a href=&quot;http://en.wikipedia.org/wiki/Base64#Examples&quot; target=&quot;_blank&quot;&gt;Wiki example&lt;/a&gt;, it is pretty much straight forward and clear.&lt;br /&gt;
Same example is given below as well..&lt;br /&gt;
&lt;table border=&quot;1&quot;&gt;&lt;tr&gt; &lt;th scope=&quot;row&quot;&gt;Text content&lt;/th&gt; &lt;td colspan=&quot;8&quot; align=&quot;center&quot;&gt;&lt;b&gt;M&lt;/b&gt;&lt;/td&gt; &lt;td colspan=&quot;8&quot; align=&quot;center&quot;&gt;&lt;b&gt;a&lt;/b&gt;&lt;/td&gt; &lt;td colspan=&quot;8&quot; align=&quot;center&quot;&gt;&lt;b&gt;n&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;th scope=&quot;row&quot;&gt;ASCII&lt;/th&gt; &lt;td colspan=&quot;8&quot; align=&quot;center&quot;&gt;77&lt;/td&gt; &lt;td colspan=&quot;8&quot; align=&quot;center&quot;&gt;97&lt;/td&gt;  &lt;td colspan=&quot;8&quot; align=&quot;center&quot;&gt;110&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;th scope=&quot;row&quot;&gt;Bit pattern&lt;/th&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt;  &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;  &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;0&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt; &lt;th scope=&quot;row&quot;&gt;Index&lt;/th&gt; &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;19&lt;/td&gt; &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;22&lt;/td&gt; &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;5&lt;/td&gt; &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;46&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;th scope=&quot;row&quot;&gt;Base64-encoded&lt;/th&gt; &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;&lt;b&gt;T&lt;/b&gt;&lt;/td&gt;  &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;&lt;b&gt;W&lt;/b&gt;&lt;/td&gt; &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;&lt;b&gt;F&lt;/b&gt;&lt;/td&gt; &lt;td colspan=&quot;6&quot; align=&quot;center&quot;&gt;&lt;b&gt;u&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
Since in Base64 you can have totally 64 different characters so your output can have characters only from the set given below:&lt;br /&gt;
A-Z, a-z, 0-9, +, /&lt;br /&gt;
&lt;i&gt;Note: last two character might change depending on the implementation, for example, in variant Base64 with URL and Filename Safe Alphabet (RFC 4648 &#39;base64url&#39; encoding) -(hyphen) and _ (underscore) are used.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
There are many variants of base64 are available, Some are listed below:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;RFC 1421&lt;/li&gt;
&lt;li&gt;RFC 2045- org.apache.commons.codec.binary.Base64 class does encoding and decoding as per this standard.&lt;/li&gt;
&lt;li&gt;RFC 3548&lt;/li&gt;
&lt;/ol&gt;See more exhaustive list &lt;a href=&quot;http://en.wikipedia.org/wiki/Base64#Variants_summary_table&quot; target=&quot;_blank&quot;&gt;here(Wiki)&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Last thing we will cover in theory is padding.. Now padding is adding extra bits/bytes/characters etc. when required. In Base64encoding also, padding is required some times.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;When does padding is done in Base64Encoding and what characters are inserted for padding?&lt;/b&gt;&lt;br /&gt;
I will not explain how padding is done. this is clearly explained on Wiki site of Base64(See Relevant References) &lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Base64#Padding&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;&lt;/i&gt;. Padding is done when the number of bytes to encode is not divisible by 3, that is there are only one or two bytes of input for the last block. The &#39;==&#39; sequence indicates that the last group contained only 1 byte, and &#39;=&#39; indicates that it contained 2 bytes (you&#39;ll like that there are implementations available which doesn&#39;t require padding at all).&lt;br /&gt;
&lt;br /&gt;
There are various implementations available as I mentioned earlier but being a good developer you should open your eyes and decide which implementation to choose depending on the requirement. Some Common applications of Base64 are given below:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;b&gt;URL:&lt;/b&gt; &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;To encode the URL query parameters&lt;/li&gt;
&lt;li&gt;To encode data in hidden form fields&lt;/li&gt;
&lt;li&gt;Just to obfuscate the URL data&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;File names:&lt;/b&gt; Variant Modified Base64 for file name uses &#39;-&#39; instead of &#39;/&#39;, because Unix and Windows file names cannot contain &#39;/&#39;.&lt;/li&gt;
&lt;/ol&gt;Checkout the &lt;a href=&quot;http://en.wikipedia.org/wiki/Base64#Other_applications&quot; target=&quot;_blank&quot;&gt;other applications&lt;/a&gt; also.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Let us jump to Base64 Encoding in Java: &lt;/b&gt; There are many implementations available. I will list them down first (not all):&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Apache commons: org.apache.commons.codec.binary.Base64. Usage of this implementation is recommended.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Sun misc package: sun.misc.BASE64Decoder. Avoid using it as misc package is never officially released by SUN, this is one thing. Another thing is Oracle might be tempted to remove all packages with names having SUN and you see that code suddenly stopped working in future releases of Java.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Base64 class shipped with JAXB framework. Use this if your project is already using JAXB.&lt;/li&gt;
&lt;li&gt;javax.mail.internet.MimeUtility: This class also has encode and decode methods and can do the job for you. But use them when your code is dealing with emails as this implementation follows MIME protocol guidelines.&lt;/li&gt;
&lt;/ul&gt;There are many others also available. You can write your own as well (all the best if you are doing.)&lt;br /&gt;
&lt;br /&gt;
Now it&#39;s time for demo code:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;import java.util.Arrays;

import org.apache.commons.codec.binary.Base64;

/**
 * @author java-espresso
 * This class has two methods one encodes a string in Base64Encoding 
 * and other decodes the same.
 */
public class CommonUtil {

 public static String base64Encode(String stringToEncode){
  byte [] stringToEncodeBytes = stringToEncode.getBytes();
  return Base64.encodeBase64String(stringToEncodeBytes);
 }
 
 public static String base64Decode(String stringToDecode){
  byte [] decodedBytes = Base64.decodeBase64(stringToDecode);
  return new String(decodedBytes);
 }
 
}
&lt;/pre&gt;Test class for the above code:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;public class TestBase64 {

 /**
  * @param args
  */
 public static void main(String[] args) {
  String testString1 = &quot;test String&quot;; //Total bytes=11 divide by 3  and 2 bytes are in remainder so &#39;=&#39; is appended in the encoded string
  String testString2 = &quot;TestString&quot;; //Total bytes=10 divide by 3  and 1 bytes are in remainder so &#39;==&#39; is appended in the encoded string
  String testString3 = &quot;Test string.&quot;; // Total bytes=12 divide by 3  and 0 bytes are in remainder so nothing is appended
  
  String encoded1= CommonUtil.base64Encode(testString1);
  String encoded2= CommonUtil.base64Encode(testString2);
  String encoded3= CommonUtil.base64Encode(testString3);
  
  System.out.println(&quot;====== Encoded Strings =======================================&quot;);
  System.out.println(testString1+&quot; &gt; Encoded &gt; &quot;+encoded1);
  System.out.println(testString2+&quot; &gt; Encoded &gt; &quot;+encoded2);
  System.out.println(testString3+&quot; &gt; Encoded &gt; &quot;+encoded3);
  
  System.out.println(&quot;====== Decoded Strings =======================================&quot;);
  System.out.println(encoded1+&quot; &gt; Decoded &gt; &quot;+CommonUtil.base64Decode(encoded1));
  System.out.println(encoded2+&quot; &gt; Decoded &gt; &quot;+CommonUtil.base64Decode(encoded2));
  System.out.println(encoded3+&quot; &gt; Decoded &gt; &quot;+CommonUtil.base64Decode(encoded3));
 }

}
&lt;/pre&gt;output on executing the above code:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;====== Encoded Strings =======================================
test String &gt; Encoded &gt; dGVzdCBTdHJpbmc=
TestString &gt; Encoded &gt; VGVzdFN0cmluZw==
Test string. &gt; Encoded &gt; VGVzdCBzdHJpbmcu
====== Decoded Strings =======================================
dGVzdCBTdHJpbmc= &gt; Decoded &gt; test String
VGVzdFN0cmluZw== &gt; Decoded &gt; TestString
VGVzdCBzdHJpbmcu &gt; Decoded &gt; Test string.
&lt;/pre&gt;&lt;i&gt;Please find the source of the application attached &lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/Base64Utils.zip&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;Related Article&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://java-espresso.blogspot.com/2011/09/md5-encryption-in-java.html&quot; target=&quot;_blank&quot;&gt;MD5 encryption and decryption in Java&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://java-espresso.blogspot.com/2011/09/des-algorithm-code-in-java.html&quot; target=&quot;_blank&quot;&gt;DES encryption and decryption in Java&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Relevant References&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Base64&quot; target=&quot;_blank&quot;&gt;Wiki-Base64&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tools.ietf.org/html/rfc2045&quot; target=&quot;_blank&quot;&gt;MIME RFC 2045&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://maxcalci.com/base64.html&quot; target=&quot;_blank&quot;&gt;Online Encode/Decode&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Binary-to-text_encoding&quot; target=&quot;_blank&quot;&gt;Wiki-Binary to text encoding&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/469695/decode-base64-data-in-java&quot; target=&quot;_blank&quot;&gt;Stackoverflow-Base64 thread&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/3670029070273115170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/10/base64-encoding-and-decoding-in-java.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3670029070273115170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3670029070273115170'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/10/base64-encoding-and-decoding-in-java.html' title='Base64 encoding and decoding in Java'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-1918001709400609686</id><published>2011-10-13T00:10:00.000-07:00</published><updated>2011-10-13T05:28:43.008-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="difference runnable and thread java"/><category scheme="http://www.blogger.com/atom/ns#" term="difference runnable thread"/><category scheme="http://www.blogger.com/atom/ns#" term="difference runnable threads"/><category scheme="http://www.blogger.com/atom/ns#" term="java thread"/><category scheme="http://www.blogger.com/atom/ns#" term="java thread example"/><category scheme="http://www.blogger.com/atom/ns#" term="java threads"/><category scheme="http://www.blogger.com/atom/ns#" term="runnable interface"/><category scheme="http://www.blogger.com/atom/ns#" term="thread basics"/><category scheme="http://www.blogger.com/atom/ns#" term="thread life cycle"/><category scheme="http://www.blogger.com/atom/ns#" term="threads java"/><title type='text'>Threads Part1: An introduction</title><content type='html'>A thread in computer science is short for a thread of execution. A thread is a single sequential flow of control within a program (i.e., process). Threads are a way for a process to split itself into multiple simultaneously running tasks. Threads are  lightweight processes  because they run within the context of a full-blown program and takes advantage of the resources allocated for that program and the program&#39;s environment. Threads are similar to process, but differ in the way that they share resources.&lt;br /&gt;Java virtual machine can support many threads of execution at once. These threads independently execute code that operates on values and objects residing in a shared main memory. Threads may be supported by having many hardware processors (where threads are executed on separate processors), by time-slicing a single hardware processor (where a single processor switches between different threads giving the illusion that they are all executing at the same time), or by time-slicing many hardware processors. There is always at least one thread within every Java program: the main() method of the class which was given as a parameter to the Java interpreter.&lt;br /&gt;&lt;br /&gt;Difference between a&lt;span style=&quot;font-style:italic;&quot;&gt; user thread&lt;/span&gt; and  &lt;span style=&quot;font-style:italic;&quot;&gt;daemon thread&lt;/span&gt;. The daemon threads purpose is to give services to the user threads which are created by the user to perform the long running task (mostly for not blocking the ui or to do something in background ).The main() method of the application is a user thread. Threads created by a user are user thread ,you can also create the Daemon thread by explicitly calling the setDaemon(true) on a Thread object.One important point here is that setDaemon() method must be called before the thread is started .Once all the user threads are terminated then only JVM will terminate not in the other way if there are Daemon threads running but no user threads then JVM will close the running application .There should be atleast one user thread(main thread is a user thread )running for the JVM not to close the application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;There are two ways of implementing threading in JAVA &lt;/span&gt;&lt;br /&gt;1) By extending java.lang.Thread class, or&lt;br /&gt;2) By implementing java.lang.Runnable interface.&lt;br /&gt;Before we go into implementation details I just like to cover when we use thread? so we use thread if we want some part of code is executed parallel and we put that code inside run() method of either Thread class or Runnable interface.&lt;br /&gt;Actually public void run () method is defined in Runnable interface and since java.lang.Thread class implements Runnable interface it gets this method automatically.&lt;br /&gt;&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;&lt;br /&gt;//implementing Thread by extending Thread class&lt;br /&gt; class MyThread extends Thread{        &lt;br /&gt;             public void run(){&lt;br /&gt;                         System.out.println(&quot;I am executing by Thread: &quot; + Thread.currentThread().getName());&lt;br /&gt;             }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; //implementing Thread by implementing Runnable interface&lt;br /&gt; class MyRunnable implements Runnable{          &lt;br /&gt;             public void run(){&lt;br /&gt;                         System.out.println(&quot;I am executing by Thread: &quot; + Thread.currentThread().getName());&lt;br /&gt;             }&lt;br /&gt; }&lt;br /&gt;//starting Thread&lt;br /&gt;        Thread mythread = new MyThread();&lt;br /&gt;         mythread.setName(&quot;T1&quot;);&lt;br /&gt;         Thread myrunnable = new Thread(new MyRunnable(),&quot;T2&quot;);&lt;br /&gt;         mythread.start();&lt;br /&gt;         myrunnable.start();&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Thread will not start until you call the start() method of java.lang.Thread class. When we call start () method Java Virtual machine execute run () method of that Thread class into separate Thread other than calling thread. Anybody guess what will happen if we call the run() method directly instead of calling start() method ?&lt;br /&gt;run() method will simply be executed in the same Thread and new Thread will not be created. Another follow up question would be what will happen if you call start () method twice in same Thread object e.g&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;&lt;br /&gt;mythread.start();&lt;br /&gt;mythread.start();// this line will throw IllegalThreadStateException&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;Difference between mythread.start() &amp; mythread.run()?&lt;/span&gt;&lt;br /&gt;• If we call mythread.start(), it will create a new Thread and that thread is responsible for execution of run().&lt;br /&gt;• If we call mythread.run(), no new thread will create, the main thread only will execute run(), just like a normal method.&lt;br /&gt;• In case of mythread.start() output we can’t expect&lt;br /&gt;• In case of mythread.run() output first it ll run the code in the run function in the main thread .&lt;br /&gt;Thread class start():-&lt;br /&gt;&lt;br /&gt;public void start()&lt;br /&gt;{&lt;br /&gt;1. Registering our thread with the thread scheduler then only thread scheduler allocate CPU and memory type of resources for this new thread also.&lt;br /&gt;2. calls run() // you can think of it as a call back invoked by the jvm &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://sites.google.com/site/espresssocontent/home/blog-blunder/Multithreading_ThreadLifeCycle.gif&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 292px;&quot; src=&quot;https://sites.google.com/site/espresssocontent/home/blog-blunder/Multithreading_ThreadLifeCycle.gif&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The thread is in the &quot;new&quot; state, once it is constructed. In this state, it is merely an object in the heap, without any system resources allocated for execution. From the &quot;new&quot; state, the only thing you can do is to invoke the start() method, which puts the thread into the &quot;runnable&quot; state. Calling any method besides the start() will trigger an IllegalThreadStateException.&lt;br /&gt;&lt;br /&gt;The start() method allocates the system resources necessary to execute the thread, schedules the thread to be run, and calls back the run() once it is scheduled. This put the thread into the &quot;runnable&quot; state. However, most computers have a single CPU and time-slice the CPU to support multithreading. Hence, in the &quot;runnable&quot; state, the thread may be running or waiting for its turn of the CPU time.&lt;br /&gt;The thread enters the &quot;not-runnable&quot; state when one of these events occurs:&lt;br /&gt;The sleep() method is called to suspend the thread for a specified amount of time and yield control to the other threads.&lt;br /&gt;&lt;br /&gt;The wait() method is called to wait for a specific condition to be satisfied.&lt;br /&gt;The thread is blocked and waiting for an I/O operation to be completed.&lt;br /&gt;For the &quot;non-runnable&quot; state, the thread becomes &quot;runnable&quot; again:&lt;br /&gt;If the thread was put to sleep, the specified sleep time expired or the sleep was interrupted via a call to the interrupt() method.&lt;br /&gt;If the thread was put to wait via wait(), its notify() or notifyAll() method was invoked to inform the waiting thread that the specified condition had been fulfilled and the wait was over.&lt;br /&gt;If the thread was blocked for an I/O operation, the I/O operation has been completed.&lt;br /&gt;A thread is in a &quot;dead&quot; state, only when the run() method terminates naturally and exits.&lt;br /&gt;&lt;br /&gt;The method isAlive() can be used to test whether the thread is alive. isAlive() returns false if the thread is &quot;new&quot; or &quot;dead&quot;. It returns true if the thread is &quot;runnable&quot; or &quot;not-runnable&quot;.&lt;br /&gt;JDK 1.5 introduces a new Thread.getState() method. This method returns an enum of type Thread.State, which takes a constant of {NEW, BLOCKED, RUNNABLE, TERMINATED, WAITING}.&lt;br /&gt;NEW: the thread has not yet started.&lt;br /&gt;RUNNABLE:&lt;br /&gt;WAITING:&lt;br /&gt;BLOCKED: the thread is blocked waiting for a monitor lock.&lt;br /&gt;TIMED_WAITING: the thread is waiting with a specified waiting time.&lt;br /&gt;TERMINATED:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;Methods in Thread Class&lt;/span&gt;&lt;br /&gt;The methods available in Thread class include:&lt;br /&gt;public void start(): Begin a new thread. JVM calls back the run() method of this class. The current thread continues.&lt;br /&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;public void run()&lt;/span&gt;: to specify the execution flow of the new thread. When run() completes, the thread terminates.&lt;br /&gt;public static sleep(long millis) throws InterruptedException: Temporarily suspend the thread and yield control to other thread for the given milliseconds. Method sleep() is thread-safe as it does not release its monitors. The method throws InterruptedException if it is awaken before the specified timing (via a call to interrupt() method). This is a static method and commonly used to pause the current thread so that the other threads can have a chance to execute. For example:&lt;br /&gt;try {&lt;br /&gt;   // suspend for 0.1 sec and give other threads a chance to run&lt;br /&gt;   sleep(100); &lt;br /&gt;} catch (InterruptedException ex) {}&lt;br /&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;public void interrupt()&lt;/span&gt;: Interrupt the sleep() method.&lt;br /&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;public boolean isAlive()&lt;/span&gt;: Return false if the thread is new or dead. Returns true if the thread is &quot;runnable&quot; or &quot;not runnable&quot;.&lt;br /&gt;public void setPriority(int p): Set the priority-level of the thread, which is implementation dependent.&lt;br /&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;public void yield()&lt;/span&gt;: suspend the current thread to allow other threads to run.&lt;br /&gt;The stop(), suspend(), and resume() methods have been deprecated in JDK 1.4, because they are not thread-safe, due to the release of monitors. See JDK API documentation for more discussion.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;What is the difference between implementing Runnable and extending Thread?&lt;/span&gt;&lt;br /&gt;One difference between implementing Runnable and extending Thread is that by extending Thread, each of your threads has a unique object associated with it, whereas implementing Runnable, many threads can share the same object instance.&lt;br /&gt;&quot;Which way of implementing Thread is better? Extending Thread class or implementing Runnable method?&lt;br /&gt;&lt;br /&gt;In my opinion implementing Runnable is better because in Java we can only extend one class so if we extend Thread class we can not extend any other class while by implementing Runnable interface we still have  that option open with us. &lt;br /&gt;Second reason which make sense to me is more on OOPS concept according to OOPS if we extend a class we provide some new feature or functionality , So if the purpose is just to use the run() method to define code its better to use Runnable interface.&lt;br /&gt;e.g&lt;br /&gt;&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;&lt;br /&gt;&lt;br /&gt;public class Espresso {&lt;br /&gt;  public static void main (String[] args) {&lt;br /&gt;    Runner r = new Runner();&lt;br /&gt;  &lt;br /&gt;    Thread t1 = new Thread(r, &quot;Thread A&quot;);&lt;br /&gt;    Thread t2 = new Thread(r, &quot;Thread B&quot;);&lt;br /&gt;    Thread s1 = new Mythread(&quot;Thread C&quot;);&lt;br /&gt;    Thread s2 = new Mythread(&quot;Thread D&quot;);&lt;br /&gt;   &lt;br /&gt;    t1.start();&lt;br /&gt;    t2.start();&lt;br /&gt;    s1.start();&lt;br /&gt;    s2.start();&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Runner implements Runnable {&lt;br /&gt;  private int counter;&lt;br /&gt;  public void run() {&lt;br /&gt;    try {&lt;br /&gt;      for (int i = 0; i != 2; i++) {&lt;br /&gt;        System.out.println(Thread.currentThread().getName() + &quot;: &quot; &lt;br /&gt;              + counter++);&lt;br /&gt;        Thread.sleep(1000);&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;    catch(InterruptedException e) {&lt;br /&gt;      e.printStackTrace();&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Mythread extends Thread {   &lt;br /&gt;  private int counter;&lt;br /&gt;  Mythread(String name)    {&lt;br /&gt;    super(name);&lt;br /&gt;  }&lt;br /&gt;  public void run()   {&lt;br /&gt;    try {&lt;br /&gt;      for (int i = 0; i != 2; i++) {&lt;br /&gt;        System.out.println(Thread.currentThread().getName() + &quot;: &quot; &lt;br /&gt;            + counter++);&lt;br /&gt;        Thread.sleep(1000);&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;    catch(InterruptedException e)     {&lt;br /&gt;       e.printStackTrace();&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;output&lt;br /&gt;Thread A: 0&lt;br /&gt;Thread B: 1&lt;br /&gt;Thread C: 0&lt;br /&gt;Thread D: 0&lt;br /&gt;Thread C: 1&lt;br /&gt;Thread B: 2&lt;br /&gt;Thread A: 3&lt;br /&gt;Thread D: 1</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/1918001709400609686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/10/threads-part1-introduction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/1918001709400609686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/1918001709400609686'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/10/threads-part1-introduction.html' title='Threads Part1: An introduction'/><author><name>Atul Gangwar</name><uri>http://www.blogger.com/profile/06120591281044864456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFTfdhrJxZuFjfuetOmbDT8q-UYHXRDQGmJAF-6C0g6q_GKT2y2ddpiD6k620VuCVcrHYn9hlVx1KKO4H9AtwVtAGYqmul2U-KQlqfaUb2_TH0S_wA4voQrF4qgzOatA/s1600/*'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-8092451404884125822</id><published>2011-10-11T13:33:00.000-07:00</published><updated>2011-10-11T13:42:39.824-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="example jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery example"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery hello world"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery tutorial"/><title type='text'>JQuery Tutorial 1: Showing alert popup</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Let me put the code first then we will do the post mortem&lt;br /&gt;
&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
&amp;lt;title&amp;gt;Insert title here&amp;lt;/title&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.5.2.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;input type=&quot;button&quot; value=&quot;Trigger Alert&quot; id=&quot;btn_trig&quot;&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
/* $(&#39;#btn_trig&#39;) gives reference to the html element whose id is passed,
 * similiar to getElementById() function. On that reference a callback function is defined
 *  syntax of callback functions is like this event( function(){ //thing you want to do on event happening}). Callback functions are called when event happens.
 *  
 */
$(&#39;#btn_trig&#39;).click(function(){
 alert(&quot;Hello World!&quot;);
} 
);
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
Try for yourself:&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.5.2.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;input type=&quot;button&quot; value=&quot;Trigger Alert&quot; id=&quot;btn_trig&quot;&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(&#39;#btn_trig&#39;).click(function(){
 alert(&quot;Hello World!&quot;);
} 
);
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/8092451404884125822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/10/jquery-tutorial-1-showing-alert-popup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8092451404884125822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8092451404884125822'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/10/jquery-tutorial-1-showing-alert-popup.html' title='JQuery Tutorial 1: Showing alert popup'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-8820695022961438458</id><published>2011-09-29T02:13:00.000-07:00</published><updated>2011-09-29T23:03:35.694-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="https"/><category scheme="http://www.blogger.com/atom/ns#" term="https tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="keystore"/><category scheme="http://www.blogger.com/atom/ns#" term="keystore tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="security tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="ssl"/><category scheme="http://www.blogger.com/atom/ns#" term="ssl tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat https"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat keystore"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat security"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat ssl"/><title type='text'>Configuring SSL in tomcat</title><content type='html'>&lt;b&gt;What is SSL?&lt;/b&gt;&lt;br /&gt;
SSL or Secure Socket Layer is a technology which allows web browsers and web servers to communicate over a secured connection. The data being sent is encrypted by one side, transmitted, then decrypted by the other side before any further processing. Essentially, it is a two way process, Browser encrypts its requests before sending them to the server and server decrypts them then server encrypts the response and the browser decrypts it. &lt;br /&gt;
&lt;br /&gt;
There is one more thing we should understand about SSL is certificates used for &lt;i&gt;Authentication&lt;/i&gt;. When the Browser places the first request to a web server over a secure connection, that server will respond to your web browser with two things, one is your page (for example ICICI Loginpage,CitiBank login page) and other is a set of credentials, in the form of a Certificate; This certificate gives information to the browser about the authenticity of the website.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Certificates and SSL&lt;/b&gt;&lt;br /&gt;
In order to implement SSL, a web server must have an associated certificate for each external IP address that accepts secure connections. Certificate acts as a identity proof for the website like your passport for you. This certificate is signed by the issuer (you can also create your self-signed certificates as well, but do not use them in production). Issuer is normally a well recognized authority like VeriSign, Thawte, Go Daddy, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Why shouldn&#39;t you use Self-signed certificates?&lt;/b&gt;&lt;br /&gt;
Hackers normally utilize the weakness of your certificate to attack and the weakness is that it is self-signed. The attack might happen, something like this, when the client attempts to connect to the server the hacker hijacks the connection(means that now your requests will go to the hacker not the server). He then sends the client his own self-signed certificate(seeing which you feel happy and say, &lt;i&gt;wow&lt;/i&gt;, now I can fill my credit card info without any prob.) which has the same name as the one present in the server&#39;s self-signed certificate. The hacker then connects to the real server himself. When the client sends data to the server the attacker reads it(might change it as well) and then sends it along to the real server. So, your credit card information might get leaked.&lt;br /&gt;
&lt;b&gt;Let us start with tomcat:&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;You need to create a keystore file to store the private key of the server using the following command.&lt;br /&gt;
Windows:&lt;br /&gt;
&lt;textarea rows=&quot;1&quot; cols=&quot;55&quot; readonly=&quot;readonly&quot; style=&quot;;color: blue;border: dashed;border-color: infotext;overflow: hidden;&quot; &gt;%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA&lt;/textarea&gt;&lt;br /&gt;
Unix:&lt;br /&gt;
&lt;textarea rows=&quot;1&quot; cols=&quot;55&quot; readonly=&quot;readonly&quot; style=&quot;;color: blue;border: dashed;border-color: infotext;overflow: hidden;&quot; &gt;$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA&lt;/textarea&gt;&lt;br /&gt;
Same is shown below:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/Create_Keystore.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; width=&quot;440&quot; src=&quot;https://sites.google.com/site/blogblunder/java-espresso/Create_Keystore.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The file will get created under the directory from which you are running the command, for example, as shown in image, the file will get created under following path: &lt;i&gt;C:\Users\dharmvir.singh&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
To specify a different location to store the keystore file(keystore in the last of the path), just modify the above command as shown below:&lt;br /&gt;
Windows:&lt;br /&gt;
&lt;textarea rows=&quot;3&quot; cols=&quot;55&quot; readonly=&quot;readonly&quot; style=&quot;;color: blue;border: dashed;border-color: infotext;overflow: hidden;&quot; &gt;%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA  -keystore /folder1/folder2/folder3/keystoreFolder/keystore&lt;/textarea&gt;&lt;br /&gt;
same way you can do in unix.&lt;br /&gt;
Sample is shown below:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/Create_Keystore_custom_path.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; width=&quot;440&quot; src=&quot;https://sites.google.com/site/blogblunder/java-espresso/Create_Keystore_custom_path.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Password used in both the example screens shots is &quot;changeit&quot; as it is the default password for tomcat.&lt;br /&gt;
The certificate can be obtained from authorities like Verisign and others.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Uncomment the following section from $CATALINA_HOME/conf/server.xml:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;xml&quot;&gt;&lt;connector port=&quot;8443&quot; protocol=&quot;HTTP/1.1&quot; SSLEnabled=&quot;true&quot;
               maxThreads=&quot;150&quot; scheme=&quot;https&quot; secure=&quot;true&quot;
               clientAuth=&quot;false&quot; sslProtocol=&quot;TLS&quot; /&gt;
&lt;/pre&gt;&lt;i&gt;$Catalina_Home &lt;/i&gt;here represents path of your tomcat home folder&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;To test it I created a sample TestServer app (I have attached tomcat with that application to download). Here is how it will look like on accessing it on localhost.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/SSL_ERROR.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;250&quot; width=&quot;440&quot; src=&quot;https://sites.google.com/site/blogblunder/java-espresso/SSL_ERROR.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;Tips on SSL:&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;SSL has encryption/decryption which is expensive so do not configure entire application on SSL. For example, Website home, adds, banners pages, sitemap page, about us page might not be put on SSL.&lt;/li&gt;
&lt;li&gt;using name-based virtual hosts on a secured connection can be problematic. This is a limitation of SSL protocol. So you can use only one certificate for one IP address.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://tomcat.apache.org/tomcat-3.3-doc/tomcat-ssl-howto.html#s10&quot;&gt;Apache-Troubleshooting SSL in tomcat&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
tomcat with SSL enabled can be downloaded from &lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/ApacheTomcat6.0.zip&quot;&gt;here&lt;/a&gt;, It contains the TestServer App as well, so just download and start the server and test it.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Relevant References&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html&quot;&gt;Apachee tomcat 5.5 SSL implementation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Secure_Sockets_Layer&quot;&gt;Wiki-SSL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/HTTP_Secure&quot;&gt;Wiki-Http Secure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Comparison_of_SSL_certificates_for_web_servers&quot;&gt;Wiki-Comparison of SSL certificates from different Authorities available on the market&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Certificate_authority&quot;&gt;Wiki-What are certificate authorities&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;i&gt;Note from Author: Please leave appreciation comment, if you like the article or else please leave your questions, suggestions or feedback.&lt;br /&gt;
Thanks,&lt;br /&gt;
java-espresso&lt;br /&gt;
&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/8820695022961438458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/configuring-ssl-in-tomcat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8820695022961438458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8820695022961438458'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/configuring-ssl-in-tomcat.html' title='Configuring SSL in tomcat'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-8742592404160499795</id><published>2011-09-28T08:17:00.004-07:00</published><updated>2012-05-18T05:48:08.851-07:00</updated><title type='text'>JAVA BASICS.. JAVA A DIFFERENT APPROACH TO START.. JAVA PLATFORM INDEPENDENT. HOW JAVA IS PORTABLE?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
Must read for a good start of JAVA&lt;br /&gt;
&lt;br /&gt;
All of us know that JAVA is portable i.e JAVA is platform independent.Let us try to figure out the reason how Java is platform independent. Java has used a slogan &lt;i&gt;Write Once Run anywhere&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Explanation:&lt;/b&gt;&lt;br /&gt;
Some language generate .obj or .exe file after compiling. These generated file will not work in other Operating system. There was a need to have something which will not depend on operating system. Hence they came with new concept of JAVA VIRTUAL MACHINE(JVM). Running a java program was divided into 2 parts. First part makes .class file and in the second part this .class file will be run on JVM.&lt;br /&gt;
For the generation of .class file from .java file,compiler was written which will always generate the same .class file for any of the operating systems. Half of the work is over for getting platform independency.&lt;br /&gt;
&lt;br /&gt;
.java&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;----&lt;/span&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;i&gt;Compile&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;----&amp;gt;&lt;/span&gt;.class(Byte Code)&lt;span style=&quot;font-size: x-small;&quot;&gt;---&lt;/span&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;i&gt;Interpreter(Platform Dependent)&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;---&amp;gt;&lt;/span&gt;machineCode&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
For running the same .class file in different OS, they made a&amp;nbsp;&lt;b&gt;difference in JVM&lt;/b&gt;&amp;nbsp;for different operating system. JVM  depends on the hardware and OS architecture. It will take .class file as input and interpret it. So for the same .class file it will generate the same output. It is the difference in JVM which has made java a platform independent language.&lt;br /&gt;
&lt;br /&gt;
Now in the next post we will learn basics of java taking memory into consideration.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/8742592404160499795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/java-basics-java-different-approach-to.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8742592404160499795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/8742592404160499795'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/java-basics-java-different-approach-to.html' title='JAVA BASICS.. JAVA A DIFFERENT APPROACH TO START.. JAVA PLATFORM INDEPENDENT. HOW JAVA IS PORTABLE?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-4124808482648337967</id><published>2011-09-23T23:44:00.000-07:00</published><updated>2012-01-11T22:54:33.571-08:00</updated><title type='text'>web.xml servlet Understanding &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Understanding the &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Other Questions of similar pattern:&lt;br /&gt;
1) How to exclude from url-pattern in servlet mapping?&lt;br /&gt;
2) To exclude content from url-pattern&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
While developing web.xml in application, do take care of the &amp;lt;url-pattern&amp;gt;.&lt;br /&gt;
Try not to give a generic url-pattern ie., &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;.The disadvantage of this URL Pattern is, any request coming to the server will fall in this URL PATTERN(except for those you have explicitly defined). Suppose browser is requesting a page which has images,css,etc then you will find page will load with the servlet response,while the images,css,js,etc are not getting loaded and it will be very difficult to find the reason for this type of behaviour.&lt;br /&gt;
&lt;br /&gt;
The reason is as:-&lt;br /&gt;
Our browser requests in the following steps&lt;br /&gt;
Step1: The browser requests the page and gets back the response which contains all other path.&lt;br /&gt;
Step2: The browser again requests all the other path to the server and these path contains the images,css,etc&lt;br /&gt;
&lt;br /&gt;
What happens in our problem is in step 2,the browser&#39;s request goes to the server and now the images,etc also falls in the &lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;url-pattern &amp;gt;/*&amp;lt;/url-pattern&amp;gt;&lt;/span&gt;&lt;/span&gt;,which redirects to a servlet and this is the problem. This is the reason why we don&#39;t get images and other files in our web page.&lt;br /&gt;
&lt;br /&gt;
Let us solve this with the help of example:&lt;br /&gt;
&lt;b&gt; web.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;xml&quot; name=&quot;code&quot;&gt;&lt;web-app&gt;
 &lt;display-name&gt;TestUrlPattern&lt;/display-name&gt;
 &lt;servlet&gt;
   &lt;servlet-name&gt;ServletDefault&lt;/servlet-name&gt;
   &lt;servlet-class&gt;com.test.ServletDefault&lt;/servlet-class&gt;
  &lt;/servlet&gt; 
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;ServletDefault&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;abcd&lt;/servlet-name&gt;
  &lt;jsp-file&gt;/abc.jsp&lt;/jsp-file&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
   &lt;servlet-name&gt;abcd&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/abc.jsp&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
&lt;/web-app&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;abc.jsp&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;xml&quot; name=&quot;code&quot;&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;TestUrlPattern&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
Sample text
&amp;lt;img src=&quot;Desert.jpg&quot; &amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Whenever a request comes as localhost:8080/TestApp/abc.jsp, the abc.jsp loads and images are not getting loaded. The images goes to the SevletDefault mapping. You can see this by printing any text in doGet or doPost method of ServletDefault class.&lt;br /&gt;
Reason is,all files other than abc.jsp will go to ServletDefault.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Solution for /* type pattern in web.xml&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I found two approaches to solve this problem&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Approach 1:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Make a common servlet which consumes all the files which have the pattern for images,css,javascript,etc&lt;br /&gt;
&lt;b&gt;web.xml &amp;nbsp;(modified)&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;xml&quot; name=&quot;code&quot;&gt;&lt;web-app&gt;
  &lt;display-name&gt;TestUrlPattern&lt;/display-name&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;CommonServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.test.CommonServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;Servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.test.Servlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;Servlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;servlet&gt;
    &lt;servlet-name&gt;abcd&lt;/servlet-name&gt;
    &lt;jsp-file&gt;/abc.jsp&lt;/jsp-file&gt;
  
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;abcd&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/abc.jsp&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
        &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;CommonServlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/images/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;CommonServlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/stylesheet.css&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;CommonServlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/javascript.js&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;  
&lt;/web-app&gt;
&lt;/pre&gt;&lt;br /&gt;
Keep the images in the &#39;images&#39; folder. For a new request to the servlet, you will find,all the images,css,js requests goes to CommonServlet. Write a CommonServlet which retuns back the file itself in the response.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CommonServlet.java&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;public class CommonServlet extends HttpServlet  {
 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws ServletException, IOException {
  ServletContext sc = getServletContext();
  String path=req.getRequestURI().substring(req.getContextPath().length()+1, req.getRequestURI().length());
     String filename = sc.getRealPath(path);

     // Get the MIME type of the image
     String mimeType = sc.getMimeType(filename);
     if (mimeType == null) {
         sc.log(&quot;Could not get MIME type of &quot;+filename);
         resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
         return;
     }
     // Set content type
     resp.setContentType(mimeType);

     // Set content size
     File file = new File(filename);
     resp.setContentLength((int)file.length());

     // Open the file and output streams
     FileInputStream in = new FileInputStream(file);
     OutputStream out = resp.getOutputStream();

     // Copy the contents of the file to the output stream
     byte[] buf = new byte[1024];
     int count = 0;
     while ((count = in.read(buf)) &amp;gt;= 0) {
         out.write(buf, 0, count);
     }
     in.close();
     out.close();
 }
}
&lt;/pre&gt;&lt;br /&gt;
The above servlet write the contents of file in the response and our problem is solved.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Approach 2:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This approach sets the context in jboss server.xml file.&lt;br /&gt;
server.xml is found at Jboss_home\server\default\deploy\jboss-web.deployer path.&lt;br /&gt;
Open server.xml in edit mode&lt;br /&gt;
Add the context in server.xml.&lt;br /&gt;
Find text similar to the following code in server.xml&lt;br /&gt;
&lt;pre class=&quot;xml&quot; name=&quot;code&quot;&gt;&amp;lt;Host name=&quot;localhost&quot;&amp;nbsp;autoDeploy=&quot;false&quot; deployOnStartup=&quot;false&quot; deployXML=&quot;false&quot;configClass=&quot;org.jboss.web.tomcat.security.config.JBossContextConfig&quot;&amp;nbsp;&amp;gt;
&lt;/pre&gt;Below the above code add the context as:&lt;br /&gt;
&lt;pre class=&quot;xml&quot; name=&quot;code&quot;&gt;&lt;context docbase=&quot;D:\Eclipse\project\TestImages\WebContent\images&quot; path=&quot;/TestProject/images&quot; privileged=&quot;true&quot; reloadable=&quot;true&quot;&gt;
&lt;/context&gt;
&lt;/pre&gt;&lt;br /&gt;
set docBase,path according to your path.This will solve your problem.&lt;br /&gt;
&lt;br /&gt;
These were the two approaches which i found out for this problem. Please let me know if you know any more approach.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/4124808482648337967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/webxml-problem-and-solution-for-url.html#comment-form' title='17 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/4124808482648337967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/4124808482648337967'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/webxml-problem-and-solution-for-url.html' title='web.xml servlet Understanding &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>17</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-6642555302903471557</id><published>2011-09-23T11:07:00.001-07:00</published><updated>2012-06-29T11:10:28.849-07:00</updated><title type='text'>4.JAVA BASICS.. IS JAVA A PURE OBJECT ORIENTED LANGUAGE..PROBLEM SOLVING.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
As you all know java is a pure Object Oriented language.&lt;br /&gt;
&lt;i&gt;Is java Really a pure Object Oriented Language?&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
The answer is &lt;b&gt;NO&lt;/b&gt;..Java is not a pure object oriented language.&lt;br /&gt;
1)The main reason for this is it does not always deal with objects.&lt;br /&gt;
int,char,float,etc are not in the form of objects and java uses them. So this is the main reason why java is not object oriented language.&lt;br /&gt;
2)The other reason is that java does not support Multiple inheritance in case of classes,but a pure object oriented language supports multiple inheritance.&lt;br /&gt;
&lt;br /&gt;
Now let us see some of the basic thing in java which is to be noted. Those who already know java can skip this.&lt;br /&gt;
&lt;br /&gt;
What is the default value of Byte?&lt;br /&gt;
Ans: NULL&lt;br /&gt;
&lt;br /&gt;
Now a question may arise in your mind,that the default value of byte is false.Your question is correct.&lt;br /&gt;
If you observe clearly,then you will find that default value of Byte is asked not byte.And Byte is a class that means it will store reference. Remember in the first java basic, i told to see the data types start with lower case.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Point to be remembered:&lt;/b&gt; In java a class is always declared with first letter as Upper case letter(This is not a rule but it is a best practice so that you never make mistake).&lt;br /&gt;
&lt;br /&gt;
Similarly you will find some more class which may confuse you like Boolean with&amp;nbsp;boolean&amp;nbsp;,Float with float,Double with double. So don&#39;t get confuse with these classes.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Now a question may arise in your mind that why they have made these confusing classes.What is the use of these classes.Your question is correct,following is the explanations for this.&lt;br /&gt;
&lt;br /&gt;
Sometimes we need objects of these primitive data types,for this Java has made WRAPPER CLASSES for these primitive data types. All the primitive data types have Wrapper Class. Now by using these Wrapper classes,we can convert these data types to Objects and can use them.&lt;br /&gt;
Following are the wrapper classes of the primitive data types&lt;br /&gt;
1)int &amp;nbsp; &amp;nbsp;--&amp;gt; Integer&lt;br /&gt;
2)byte &amp;nbsp; --&amp;gt;Byte&lt;br /&gt;
3)short &amp;nbsp; ---&amp;gt; Short&lt;br /&gt;
4)char &amp;nbsp; &amp;nbsp;---&amp;gt;Character&lt;br /&gt;
5)boolean &amp;nbsp;--&amp;gt; Boolean&lt;br /&gt;
6)float &amp;nbsp; &amp;nbsp;---&amp;gt;Float&lt;br /&gt;
7)double &amp;nbsp; ---&amp;gt;Double&lt;br /&gt;
8)long &amp;nbsp; &amp;nbsp; ---&amp;gt;Long&lt;br /&gt;
9)void &amp;nbsp; &amp;nbsp;---&amp;gt; Void&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Compilation of program:&lt;/b&gt;&lt;br /&gt;
The java compiler search for a particular signature in the main function.&lt;br /&gt;
The signature is&lt;br /&gt;
&lt;i&gt;public static void main(String[] args)&lt;/i&gt;&lt;br /&gt;
This is the signature,that should exist in a program to run ,otherwise it will not run.&lt;br /&gt;
&lt;br /&gt;
Example for the above concept&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;Class A
{
public static void main(String[] args)
{
&amp;nbsp; &amp;nbsp; &amp;nbsp;main(&#39;x&#39;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(&quot;my string&quot;);
}
public static void main(char b)
{
&amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(b);
}
}
&lt;/pre&gt;&lt;br /&gt;
&lt;i&gt;Output&lt;/i&gt;: x&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; my string&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Reason:&lt;/i&gt; It will only treat the first main method as the main method as it is having proper signature and treats 2nd method like a normal java method.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Example2:Count how many objects are created and how many references exist:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Eg:&lt;br /&gt;
Customer a=new Customer();&lt;br /&gt;
Customer b=new Customer();&lt;br /&gt;
Customer c=a;&lt;br /&gt;
Customer d= b;&lt;br /&gt;
new Customer();&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Ans&lt;/i&gt;: 3 Objects 4 references&lt;br /&gt;
&lt;br /&gt;
In these types of questions just count the number of new keywords that will give you the number of objects.&lt;br /&gt;
and count the number of references by the class name count and in some examples please make the heap and object diagram which we made earlier and then there will be no mistakes.&lt;br /&gt;
&lt;br /&gt;
In next we will learn the concept of static in java..So keep reading...&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/6642555302903471557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/4java-basics-is-java-pure-object.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/6642555302903471557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/6642555302903471557'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/4java-basics-is-java-pure-object.html' title='4.JAVA BASICS.. IS JAVA A PURE OBJECT ORIENTED LANGUAGE..PROBLEM SOLVING.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-3358834936532866113</id><published>2011-09-23T10:05:00.000-07:00</published><updated>2011-10-07T08:33:35.467-07:00</updated><title type='text'>3.JAVA BASICS.. CLASS AND OBJECTS WITH APPROACH OF MEMORY</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;What is a class?&lt;/b&gt;&lt;br /&gt;
We can say class is a template of an object. Objects exists in memory. Class is just a way to define a structure of object.&lt;br /&gt;
&lt;br /&gt;
Now we start with discussion of memory.&lt;br /&gt;
Four segments of memory&lt;br /&gt;
1)Data segment&lt;br /&gt;
2)Code segment&lt;br /&gt;
3)Stack segment&lt;br /&gt;
4)Heap segment&lt;br /&gt;
&lt;br /&gt;
In C we have seen the use of code and data segment. But in java we will be dealing with Stack Segment and Heap Segment.&lt;br /&gt;
&lt;br /&gt;
See the example below&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57z2YsRRw2XLcwcfij2_3tCT7I8IGe0sdTVFx8DeQIFoGKoiuDLl6V6vnDSfefm_M-qFC1Dp-vJe65XdDJTuIsW-KsUI3mqRiTBquxwzfFnuNkVSmPZ2QAbvjqfk_VeQBKEPJ4Wi74QlP/s1600/JavaObjectAndReference.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;121&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57z2YsRRw2XLcwcfij2_3tCT7I8IGe0sdTVFx8DeQIFoGKoiuDLl6V6vnDSfefm_M-qFC1Dp-vJe65XdDJTuIsW-KsUI3mqRiTBquxwzfFnuNkVSmPZ2QAbvjqfk_VeQBKEPJ4Wi74QlP/s400/JavaObjectAndReference.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
When we write using new keyword, a new object is created and &lt;i&gt;new Customer()&lt;/i&gt; returns the hashcode of the created object. The variable used to store the hash code value is called &lt;i&gt;reference &lt;/i&gt;variable.It is called reference because it has the hash code value,which refers to an object.&lt;br /&gt;
&lt;br /&gt;
In short we can say that obj(the variable used above) stores the hash code,where hash code is not the actual address(it is changed to hash code by some hash algorithm). Java does not deal with direct memory,it deals with hash code and the hash code &amp;nbsp;indirectly refers to a memory. This is the reason why java is called secure. Unlike C,it has no pointers or depointers which can take you to the actual memory address.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Suggestions:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
When ever dealing with output problems,always make a heap by making a square and see the code for how many objects are there. Count and make that many ovals inside the square and point these objects by an arrow of reference. I assure you by using this method,you will not make any mistakes. Example is below&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE2d-FDpAOTt8w0k-oFXmBP_cjN1ERPVAqRI4LL5Vh8aFVwlV0oxKpEDKsSbeH02ZUFHFDSmfBW1aEGHuSUM4GaNMr5-tm-JqEL0abH7TRuw37JNn261JjptXaXPaOWbA6tpOIoUT-MPms/s1600/HeapWithObjects.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;230&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE2d-FDpAOTt8w0k-oFXmBP_cjN1ERPVAqRI4LL5Vh8aFVwlV0oxKpEDKsSbeH02ZUFHFDSmfBW1aEGHuSUM4GaNMr5-tm-JqEL0abH7TRuw37JNn261JjptXaXPaOWbA6tpOIoUT-MPms/s400/HeapWithObjects.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Now an important note,to be always kept in mind and will solve all your problems.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;&lt;i&gt;&amp;nbsp;Local Variables &amp;nbsp; -------&amp;gt; &amp;nbsp;STACK&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #cc0000;&quot;&gt;&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Global Variables &amp;nbsp;-------&amp;gt; &amp;nbsp; HEAP&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
Keep the above note always in your mind and there will never be a chance of mistake.Here global refers to be a part of class definition.&lt;br /&gt;
&lt;i&gt;Stack Variables do not have any default value&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Heap variables have default value. &lt;/i&gt;I&lt;i&gt;f there is any variable in Stack and you try to use that variable without initialization then it will result in a compile time error.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;All the objects which are created using new keyword,goes to heap memory,while the location of these references depends,whether they are local or global&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;Take a simple example::&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Sample sample=new Sample();&lt;br /&gt;
Here the object of class Sample will always be in heap memory,while the reference(sample here) &amp;nbsp;location depends on whether it is declared locally or global. We can say that if sample is inside a method then it will be in stack,and if it is inside a class(but outside methods) then it will be stored in heap memory.&lt;br /&gt;
&lt;br /&gt;
Default values of all the variables(only Heap Variables)&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;int &amp;nbsp; &amp;nbsp; &amp;nbsp; ---&amp;gt; 0
byte &amp;nbsp; &amp;nbsp; ---&amp;gt;0
short &amp;nbsp; &amp;nbsp;---&amp;gt;0
boolean --&amp;gt;false
long &amp;nbsp; &amp;nbsp;----&amp;gt;0
float &amp;nbsp; &amp;nbsp; ----&amp;gt;0.0f
double &amp;nbsp;----&amp;gt;0.0
char &amp;nbsp; &amp;nbsp; -----&amp;gt;&#39;\0&#39;
Reference Variable &amp;nbsp; ---&amp;gt; NULL
&lt;/pre&gt;&lt;br /&gt;
NOTE: From above,keep in mind,all variables &amp;nbsp;keep 0 as the default value.. false(boolean) can be related with 0,NULL can be related with 0,&#39;\0&#39; can be related with 0. Keep in mind a default value of 0.&lt;br /&gt;
&lt;br /&gt;
By seeing any class you can relate the variables with stack and heap.&lt;br /&gt;
&lt;br /&gt;
We will do some examples and then proceed&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;Class Sample{
int a;                //   Global Variable =&amp;gt;heap              
void printVariable()
{
int b;               //     Local Variable =&amp;gt; Stack                 
System.out.println(a);
System.out.println(b);                         ///Error
}
}
&lt;/pre&gt;&lt;br /&gt;
Why Error?&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;The reason is that b is a local variable. We are trying to use a local variable,which is not initialized,and stack variable don&#39;t have &amp;nbsp;default value so it gives error.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Comparison with C language: In C also,global variables prints 0 while the local variable gives Garbage Value.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Java does not want to have these garbage values because that will make your code buggy,so Java compiler is checking for this at compile time only and thus ,doesn&#39;t allow the code to compile.&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Example 2:&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;Class Sample{
Test obj;            //   suppose Test is another class
int a;
void printVariables()
{
System.out.println(&quot;value of a is:&quot;+a);
System.out.println(&quot;value of reference:&quot;+obj);
}
}
&lt;/pre&gt;Ans: As we can see that both are global variables,means both use heap memory.&lt;br /&gt;
None of them is initialized,so default value is printed.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; value of a is: 0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; value of reference: NULL&lt;br /&gt;
&lt;br /&gt;
Example 3:&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;class Sample{
void printArea()
{
&amp;nbsp;int a;
int b=1;
if(b==1)
{
a=10;
}
System.out.println(a);
}
&lt;/pre&gt;Ans: Compile Time Error&lt;br /&gt;
Now the question that come in your mind, the local variable is initialized before using,then why it gives compile time error.&lt;br /&gt;
&lt;b&gt;Reason:&lt;/b&gt; Even though you have initialized the variable,but at compile time, the compiler does not know in advance if it will enter the loop or not at run time. If&amp;nbsp;suppose,at run time it does not enter the loop and the variable will not get initialized. To avoid these type of situations at run time,java is designed such a way,if a variable is not initialized and gets initialized in inner loops,it does not matter. So if any variable is initialized in inner loop but not in the loop where it is declared,and we use the variable in the declaration loop,the code will not compile.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/3358834936532866113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/3java-basics-class-and-objects-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3358834936532866113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3358834936532866113'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/3java-basics-class-and-objects-with.html' title='3.JAVA BASICS.. CLASS AND OBJECTS WITH APPROACH OF MEMORY'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh57z2YsRRw2XLcwcfij2_3tCT7I8IGe0sdTVFx8DeQIFoGKoiuDLl6V6vnDSfefm_M-qFC1Dp-vJe65XdDJTuIsW-KsUI3mqRiTBquxwzfFnuNkVSmPZ2QAbvjqfk_VeQBKEPJ4Wi74QlP/s72-c/JavaObjectAndReference.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-7353581978650647459</id><published>2011-09-23T08:21:00.000-07:00</published><updated>2011-10-07T09:53:40.125-07:00</updated><title type='text'>2. JAVA BASICS..JAVA PRIMITIVE DATA TYPES.. A CORRECT WAY TO START JAVA</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
There are 8 primitive java data type&lt;br /&gt;
&lt;br /&gt;
We will write the java data types in increasing order of their size (in bytes).&lt;br /&gt;
&lt;br /&gt;
boolean&amp;lt;byte&amp;lt;short ,char &amp;lt;int,float&amp;lt;long,double&lt;br /&gt;
&amp;nbsp; &amp;nbsp; (1) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(1) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(2) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(4) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(8)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Please notice, all data type start with a&amp;nbsp;&lt;b&gt;lowercase letter.&lt;/b&gt;&lt;br /&gt;
We will derive the possible values of these data types,according to the size of data type.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;byte:&lt;/b&gt;&amp;nbsp;memory =1byte=8 bits&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;1(signed bit)&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 &amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; 0&lt;br /&gt;
Our computer store numbers in 2&#39;s complement format.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Calculating the max value.&lt;/i&gt;&lt;br /&gt;
Signed bit=0 for positive number.Below is the format shown&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;0(signed bit)&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 &amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;max value &lt;/i&gt;:&lt;br /&gt;
&amp;nbsp;(0*2&lt;sup&gt;7&lt;/sup&gt;)+2&lt;sup&gt;6&lt;/sup&gt;+2&lt;sup&gt;5&lt;/sup&gt;+2&lt;sup&gt;4&lt;/sup&gt;+2&lt;sup&gt;3&lt;/sup&gt;+2&lt;sup&gt;2&lt;/sup&gt;+2&lt;sup&gt;1&lt;/sup&gt;+2&lt;sup&gt;0&lt;/sup&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;=&amp;gt; 127&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;=&amp;gt; 2&lt;sup&gt;7&lt;/sup&gt;-1&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Min value:&lt;/i&gt;&lt;br /&gt;
Taking the signed bit as 1, i.e negative number. For getting lowest -ve we make all other bits to 0&lt;br /&gt;
Below is the format shown&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;1(signed bit)&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 &amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Calculated value&lt;/i&gt; is &amp;nbsp; &amp;nbsp; (-2&lt;sup&gt;7&lt;/sup&gt;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; =&amp;gt; -128&lt;br /&gt;
&lt;br /&gt;
The range of byte&amp;nbsp;&amp;nbsp;as derived is: -2&lt;sup&gt;7&lt;/sup&gt;&amp;nbsp;to (2&lt;sup&gt;7&lt;/sup&gt;-1) &amp;nbsp; &amp;nbsp; &amp;nbsp;OR &amp;nbsp;-128 to 127&lt;br /&gt;
&lt;br /&gt;
Analyse the above in powers of 2. You will find that for 8 bits it comes to power 7.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;short:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&amp;nbsp;size=2 bytes= 16 bits&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;1(signed bit)&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 14 &amp;nbsp;13 &amp;nbsp; 12 &amp;nbsp;11 &amp;nbsp; 10 &amp;nbsp; 9 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; 7 &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;max value:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;0(signed bit)&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 14 &amp;nbsp;13 &amp;nbsp; 12 &amp;nbsp;11 &amp;nbsp; 10 &amp;nbsp; 9 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; 7 &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Calculated value:&lt;/i&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; =&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;sup&gt;0&lt;/sup&gt;+2&lt;sup&gt;1&lt;/sup&gt;+2&lt;sup&gt;2&lt;/sup&gt;+.............+2&lt;sup&gt;14&lt;/sup&gt;&amp;nbsp;{Geometric progression formulla a(r&lt;sup&gt;n+1&lt;/sup&gt;-1)/(r-1)}&lt;br /&gt;
here a=1,r=2,n=14&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;=&amp;gt; 1+2&lt;sup&gt;1&lt;/sup&gt;+2&lt;sup&gt;2&lt;/sup&gt;+......2&lt;sup&gt;14&lt;/sup&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;=&amp;gt; (2&lt;sup&gt;15&lt;/sup&gt;-1)&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Min Value:&lt;/i&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;1(signed bit)&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 0 &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 14 &amp;nbsp;13 &amp;nbsp; 12 &amp;nbsp;11 &amp;nbsp; 10 &amp;nbsp; 9 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; 7 &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
calculated value: &amp;nbsp; -2&lt;sup&gt;15&lt;/sup&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Range:&lt;/i&gt; -2&lt;sup&gt;15&lt;/sup&gt;&amp;nbsp;to (2&lt;sup&gt;15&lt;/sup&gt;-1) &amp;nbsp; &amp;nbsp; &amp;nbsp;OR -32768 to 32767&lt;br /&gt;
&lt;br /&gt;
Here 2 bytes=16bits -----&amp;gt; Range in power of 15&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;char:&lt;/b&gt;&lt;br /&gt;
Don&#39;t consider the signed bit here as characters cannot be -ve.&lt;br /&gt;
Java follows unicode characters,and cannot be placed in 1 byte as 1 byte can contain a max of 255 chars.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;max value:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;1&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp; 1 &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15 &amp;nbsp; 14 &amp;nbsp;13 &amp;nbsp; 12 &amp;nbsp; 11 &amp;nbsp;10 &amp;nbsp; 9 &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; 7 &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; 0&lt;br /&gt;
All 1&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp;=&amp;gt; 2&lt;sup&gt;0&lt;/sup&gt;&amp;nbsp;+2&lt;sup&gt;1&lt;/sup&gt;+......+2&lt;sup&gt;15&lt;/sup&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;=&amp;gt; (2&lt;sup&gt;16&lt;/sup&gt;-1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: inherit;&quot;&gt;65535&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: arial, sans-serif; font-size: 18px;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;i&gt;Min Value:&lt;/i&gt; &amp;nbsp;all 0&#39;s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; =&amp;gt; 0&lt;br /&gt;
&lt;i&gt;Range:&lt;/i&gt; 0 to 65535&lt;br /&gt;
&lt;br /&gt;
We can say,char supports a max of 65535 characters.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;int:&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;4 bytes=32 bits&lt;br /&gt;
See the above derivation for short,byte and you will be able to write the range of integers.&lt;br /&gt;
The range comes &amp;nbsp;-2&lt;sup&gt;31&lt;/sup&gt;&amp;nbsp;to (2&lt;sup&gt;31&lt;/sup&gt;-1)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;long:&lt;/b&gt;&lt;br /&gt;
8 bytes=64 bits&lt;br /&gt;
&lt;i&gt;Range: &amp;nbsp;&lt;/i&gt; -2&lt;sup&gt;63&lt;/sup&gt;&amp;nbsp;&amp;nbsp;to (2&lt;sup&gt;63&lt;/sup&gt;-1)&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;From the above discussion,it is clear,we don&#39;t have to learn these ranges,just calculate the number of bits and you will be able to write the range directly without any calculation.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;float(Calculation for float range)&lt;/b&gt;&lt;br /&gt;
It follows IEEE 754 standard.&lt;br /&gt;
According to which 1 bit is fixed for sign. 23 for Mantissa and 8 bits for Exponent&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&amp;nbsp;1(signed bit){s}&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&amp;lt;------23 bits(Mantissa)--------&amp;gt; {M} &amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&amp;lt;----8 bits(Exponent)---&amp;gt;{E} &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Formula&amp;nbsp;for Calculation of Value is:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;=&amp;gt; &amp;nbsp;(-1)&lt;sup&gt;s&lt;/sup&gt;&amp;nbsp;* M* B&lt;sup&gt;E&lt;/sup&gt;&lt;br /&gt;
where base B is fix by designer.&lt;br /&gt;
&lt;br /&gt;
Mantissa is assumed to be in decimal i.e its value start from 1.{caculated value}&lt;br /&gt;
M=1.{calculated Mantissa value}&lt;br /&gt;
&lt;br /&gt;
Assume,all mantissa bits to be 1:&lt;br /&gt;
Calculated value is: &amp;nbsp; 2&lt;sup&gt;-1&lt;/sup&gt;+2&lt;sup&gt;-2&lt;/sup&gt;+.....+2&lt;sup&gt;-23 &amp;nbsp;&lt;/sup&gt;= 1-2&lt;sup&gt;-23&lt;/sup&gt;= &amp;nbsp; &amp;nbsp;0.999999880790071044921&lt;br /&gt;
Mantissa is: 1.999999880790071044921&lt;br /&gt;
Exponent is stored in &lt;i&gt;excess &lt;/i&gt;127 format. E is 8 bits. No signed bit in exponent,calculated range is 0 to 255.&lt;br /&gt;
Actual range is calculated by subtracting 127 from stored exponent value. Values 0,255 are fixed for special purpose. As M=1.{some value}, it can never be 0, and also the number cannot be 0. For this reason 0,255 were fixed for special purpose, which otherwise are not possible. Following are the special cases.&lt;br /&gt;
a) If M=0,E=0 &amp;nbsp; &amp;nbsp;=&amp;gt; Number is 0&lt;br /&gt;
b) If &amp;nbsp;M=0, E=255 &amp;nbsp; =&amp;gt; Number is +ve Infinity&lt;br /&gt;
c) If M={any value} ,E=0 =&amp;gt; Number is -ve Infinity&lt;br /&gt;
d) If M={any value}, E=255 &amp;nbsp;=&amp;gt; NaN(Not a Number)&lt;br /&gt;
Actual range of Exponent(subtracting 127 and not taking special case value): -126 to 127&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Max Value(positive)&lt;/i&gt;=&amp;nbsp;1.999999880790071044921 * 2&amp;nbsp;&lt;sup&gt;127&lt;/sup&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;=&amp;gt;&lt;/span&gt;3.40282346638528860e+38 &amp;nbsp;(calculated &amp;nbsp;from calculator)&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Min Value&lt;/i&gt; &amp;nbsp;: -ve of Max Value&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Float range&lt;/i&gt;&amp;nbsp;: (-1.999999880790071044921 * 2&amp;nbsp;&lt;sup&gt;127&lt;/sup&gt;) &amp;nbsp; &amp;nbsp;to&amp;nbsp;1.999999880790071044921 * 2&amp;nbsp;&lt;sup&gt;127&lt;/sup&gt;&lt;br /&gt;
OR &amp;nbsp;-3.40282346638528860e+38 &amp;nbsp; &amp;nbsp;to &amp;nbsp; &amp;nbsp;&amp;nbsp;3.40282346638528860e+38&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Minimum positive value&lt;/i&gt;= 1* M * 2&amp;nbsp;&lt;sup&gt;-126 &lt;/sup&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 11px;&quot;&gt;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;=&amp;gt; 1.75494e-38 (M=1 for making it the smallest possible positive number,which means all the mantissa bits are 0)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;The positive values range from 1.75494e-38 to 3.40282346638528860e+38&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif;&quot;&gt;Range&amp;nbsp;Magnitude&amp;nbsp;Minimum(Denormalized)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif;&quot;&gt;&amp;nbsp; { Here,they take min value as 2&lt;sup&gt;E(min)-no. of mantissa digits&lt;/sup&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;=1* 2&lt;sup&gt;-126-23&lt;/sup&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;=&amp;gt; &amp;nbsp;2&lt;sup&gt;-149&lt;/sup&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;=&amp;gt; 1.4012 e -45&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;We can say that min positive number is&amp;nbsp;1.4012 e -45.&lt;/span&gt;&lt;br /&gt;
Positive number range is&amp;nbsp;1.4012 e -45 &amp;nbsp;to &amp;nbsp;&amp;nbsp;3.40282346638528860e+38 &amp;nbsp; &amp;nbsp; --&amp;gt;(1)&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Similarly maximum -ve number possible is (-1.4012 e -45)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Similarly,-ve number range is (-3.40282346638528860e+38) to&amp;nbsp;(-1.4012 e -45) &amp;nbsp; &amp;nbsp; &amp;nbsp;---&amp;gt;(2)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; The derivations (1) and (2) are the ranges which you will find in text books.This denotes the minimum possible positive number and also the minimum possible difference between 2 numbers. Similarly we can calculate the maximum possible difference by calculating the difference between the largest possible number and the 2nd highest possible number.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;double:&lt;/b&gt;&lt;br /&gt;
8bytes=64 bits&lt;br /&gt;
Mantissa - 52 bits&lt;br /&gt;
Signed -1 bit&lt;br /&gt;
Exponent- 11 bits&lt;br /&gt;
&lt;br /&gt;
Same as the above method,we can calculate the positive and negative range for double.&lt;br /&gt;
I have not calculated,i am writing the book range&lt;br /&gt;
&amp;nbsp;4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;But the method is similar.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Please calculate once.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;TYPE CONVERSION&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Now think type conversion in simple terms.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;If we try to save information from more number of bits space to a smaller number of bits space.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Is this possible?? Ask the question to yourself.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Not satisfied.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Try to save 111111111111111 in 8 bits. It is obvious that some bits will be lost.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;Think the other way around try to save 8 bits in 16 bits. It is easily possible without loss of information.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To avoid this problem the java designers thought,the loss of information should not happen. They fixed ,you cannot convert from higher to lower but lower to higher is allowed.&lt;br /&gt;
But in explicit it is possible to convert from higher to lower,which means that you agree for loss of information.&lt;br /&gt;
&lt;br /&gt;
Below you find the lowest to highest (one way)&lt;br /&gt;
&lt;i&gt;byte&amp;lt;short,char&amp;lt;int&amp;lt;long&amp;lt;float&amp;lt;double.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
You will find that &amp;nbsp;long(8 bytes) and float(4 bytes).&lt;br /&gt;
Now you will ask how is it possible.&lt;br /&gt;
See the highest value possible for long which is&amp;nbsp;(2&lt;sup&gt;63&lt;/sup&gt;-1) while the highest possible value for float which is&amp;nbsp;1.999999880790071044921 * 2&amp;nbsp;&lt;sup&gt;127&amp;nbsp;&lt;/sup&gt;&lt;br /&gt;
which is much more than max possible value of long. There will be loss of precision but the value can be stored in that.&lt;br /&gt;
This is how the type conversion works.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;EXAMPLES&lt;/b&gt;&lt;br /&gt;
Now we will see few examples and try to learn the type casting.&lt;br /&gt;
=&amp;gt; In java,default decimal values are treated as &lt;i&gt;double.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
1)int a=10.1;&lt;br /&gt;
&lt;br /&gt;
The above code will give Compile time error.. Why??&lt;br /&gt;
RHS is of type double and LHS is of type int. So we are trying to save big in a small one.Is it possible?&lt;br /&gt;
No Bigger data type to &amp;nbsp;smaller data type is not possible.&lt;br /&gt;
&lt;br /&gt;
2) float b=7.2&lt;br /&gt;
&lt;br /&gt;
The above code will give Compile time error.. Why??&lt;br /&gt;
RHS is double and LHS is float.&amp;nbsp;Bigger data type to &amp;nbsp;smaller data type is not possible.&lt;br /&gt;
&lt;br /&gt;
3) byte b=10,c=20;&lt;br /&gt;
byte d=b+c;&lt;br /&gt;
&lt;br /&gt;
The above code will give Compile time error.. Why??&lt;br /&gt;
The reason behind this is that the arithmetic calculations are treated as integers in java.&lt;br /&gt;
So b+c is an integer and this integer value we are saving in byte which is not possible&lt;br /&gt;
so correct way is byte d=(byte)(b+c)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/7353581978650647459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/java-basicsjava-primitive-data-types.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/7353581978650647459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/7353581978650647459'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/java-basicsjava-primitive-data-types.html' title='2. JAVA BASICS..JAVA PRIMITIVE DATA TYPES.. A CORRECT WAY TO START JAVA'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-5443666719447643558</id><published>2011-09-23T08:14:00.000-07:00</published><updated>2011-10-07T08:03:04.841-07:00</updated><title type='text'>Eclipse connection through proxy server for update</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Most of the companies have proxy server in between internet and your computer.For update we need connect to internet but the proxy server requires authentication for that. And we are not able to connect to internet through Eclipse.&lt;br /&gt;
&lt;br /&gt;
Solution to the problem.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;Step 1)&lt;/b&gt;If you know the proxy server name and port number then go to step 2. If you don&#39;t know the proxy settings then open internet Explorer.Go to&lt;b&gt;&amp;nbsp;&lt;i&gt;tools-&amp;gt;Internet Options-&amp;gt;Connections(Tab)-&amp;gt;LAN settings&lt;/i&gt;.&amp;nbsp;&lt;/b&gt;You will see something as follows&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgih24-_PypW6LUXeVTKiQAkdSZWA9tO_yr8ADCNxnIK7QzYJSzj99vjjJAbio81WM_kNyoWdmjJmGGkGku1LXWjj94L2PH28lQCvPJJr8pVlC4VlOwMNvdK3XdspasviDeOAf9wPgy5c/s1600/Eclipse.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgih24-_PypW6LUXeVTKiQAkdSZWA9tO_yr8ADCNxnIK7QzYJSzj99vjjJAbio81WM_kNyoWdmjJmGGkGku1LXWjj94L2PH28lQCvPJJr8pVlC4VlOwMNvdK3XdspasviDeOAf9wPgy5c/s400/Eclipse.jpg&quot; width=&quot;390&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Out of three check boxes may be only one is checked.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Find the check box which is checked&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;a)&lt;/b&gt;&amp;nbsp;If the first check box is checked then there is no proxy required&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;b)&lt;/b&gt;&amp;nbsp;If the second is checked copy the URL for &quot;&lt;b&gt;pac&lt;/b&gt;&quot; file and open in a browser and download it and then open it. There may be many servers with ports defined in the file. You can choose any one. I chose the last one with IP address and port number. This is how you will get proxy server and port number&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;&lt;b&gt;c)&amp;nbsp;&lt;/b&gt;If the third is checked then you can directly take Address as proxy Server and port as port number.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In above image for example you can see the proxy server as sample/gate.net and port as 100&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In this &amp;nbsp;step you get proxy server and port number.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;Step 2:&lt;/b&gt;&amp;nbsp;Open the Eclipse&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;a)&lt;/b&gt;&amp;nbsp;Go to&amp;nbsp;&lt;i&gt;&lt;b&gt;Window-&amp;gt;Preferences&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;b)&lt;/b&gt;&amp;nbsp;Go to&amp;nbsp;&lt;i&gt;&lt;b&gt;General tab -&amp;gt; Network Connections&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&amp;nbsp;After this you may find one of the following screens depending on the version of Eclipse&lt;/div&gt;&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXeunX4OVFxzekaDRtydnSwnNO9peUqRkD7YBj7CdlVCqv-3RscrmEtrusLto0FRlQyq4BwL3DLx5lPX1Fh8GaaDhYr2chitY9rJKjnWLqJ7gKDRtTDTuk1MmiCDDYQLO-9D8Z_UbFnYQ/s1600/EclipseProxy.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;260&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXeunX4OVFxzekaDRtydnSwnNO9peUqRkD7YBj7CdlVCqv-3RscrmEtrusLto0FRlQyq4BwL3DLx5lPX1Fh8GaaDhYr2chitY9rJKjnWLqJ7gKDRtTDTuk1MmiCDDYQLO-9D8Z_UbFnYQ/s400/EclipseProxy.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 13px; text-align: center;&quot;&gt;Screen 1&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0-t3WPp4fJhntHykCkWjqjMQWbl_FbSsGWjrqtuT78Guaen7DmEmBkyPC43LKElYAHDztaPh4gOnfTbgB3IogpVG2T04-XfgPZWnEk3WHxiRny-VOk2LUL9wNmG1pJ1Rk9pA6lRKdtWo/s1600/EclipseProxy1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;365&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0-t3WPp4fJhntHykCkWjqjMQWbl_FbSsGWjrqtuT78Guaen7DmEmBkyPC43LKElYAHDztaPh4gOnfTbgB3IogpVG2T04-XfgPZWnEk3WHxiRny-VOk2LUL9wNmG1pJ1Rk9pA6lRKdtWo/s400/EclipseProxy1.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;font-size: 13px; text-align: center;&quot;&gt;Screen 2&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;i)Screen 1:&lt;/b&gt;&amp;nbsp;&amp;nbsp;From the Active provider&amp;nbsp;&lt;i&gt;drop down&lt;/i&gt;&amp;nbsp;Select&amp;nbsp;&lt;i&gt;&quot;manual&quot;&lt;/i&gt;&amp;nbsp;then you will find 3 Check boxes as shown in screen 1 automatically gets checked. Now Double click on any of the checked Check Boxes a new small window will open where you will be prompted to enter Host, port, Username and password.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In the host Text Field enter the proxy server name which we got in step 1 and also enter the port number.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In the username and password enter the user name and password you got from your company(it may be same as your desktop password). Repeat this for all three check boxes and click apply and then Ok.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;So now you are done with proxy setting in eclipse.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;ii) Screen 2:&lt;/b&gt;&amp;nbsp;Click on Radio Button&lt;i&gt;&amp;nbsp;Manual proxy Configuration&lt;/i&gt;. You can directly see to enter the Http proxy,SSL proxy,SOCKS proxy. So enter here the proxy server and port number. Below you will find to enter User Name and password. Enter the desired user name and password and you are finish with the work.Click Apply and Ok&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Now you can directly update the Eclipse with your proxy server also.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Please feel free to tell if there is anything wrong in this blog or any update is needed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/5443666719447643558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/eclipse-connection-through-proxy-server.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5443666719447643558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5443666719447643558'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/eclipse-connection-through-proxy-server.html' title='Eclipse connection through proxy server for update'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgih24-_PypW6LUXeVTKiQAkdSZWA9tO_yr8ADCNxnIK7QzYJSzj99vjjJAbio81WM_kNyoWdmjJmGGkGku1LXWjj94L2PH28lQCvPJJr8pVlC4VlOwMNvdK3XdspasviDeOAf9wPgy5c/s72-c/Eclipse.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-5628020107732497604</id><published>2011-09-21T04:32:00.000-07:00</published><updated>2011-09-27T13:56:09.820-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Encryption java"/><category scheme="http://www.blogger.com/atom/ns#" term="DES in java"/><category scheme="http://www.blogger.com/atom/ns#" term="des java"/><category scheme="http://www.blogger.com/atom/ns#" term="java des"/><title type='text'>DES algorithm Code in Java</title><content type='html'>&lt;b&gt;Introduction of DES&lt;/b&gt;&lt;br /&gt;
The Data Encryption Standard (DES) is a &lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Symmetric-key_algorithm&quot;&gt;symmetric-key algorithm &lt;/a&gt;&lt;/i&gt; that uses a 56-bit key.Symmetric-key encryption means it uses same key to cipher and decipher the message. DES was developed in IBM under the name of LUCIFER. DES is now considered to be insecure for many applications(especially Govt., defense). For applications demanding more security of the content, &lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Triple_DES&quot;&gt;Triple-DES&lt;/a&gt;&lt;/i&gt; can be used.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Coding DES in Java&lt;/b&gt;&lt;br /&gt;
Code listing below contains the Cryptography class which has both encryption and decryption method.&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;import java.io.IOException;
import java.security.InvalidKeyException;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

/**
 * @author dharmvir.singh 
 * The class demonstrates the DES algorithm by using java
 * crypto API
 */
public class Cryptography {
 private static final String CRYPTOGRAPHY_ALGO_DES = &quot;DES&quot;;
 private static Cipher cipher = null;
 private static DESKeySpec keySpec = null;
 private static SecretKeyFactory keyFactory = null;
 
 public static String encrypt(String inputString, String commonKey)
   throws InvalidKeyException, IllegalBlockSizeException,
   BadPaddingException {
  String encryptedValue = null;
  SecretKey key = getSecretKey(commonKey);
  cipher.init(Cipher.ENCRYPT_MODE, key);
  byte[] inputBytes = inputString.getBytes();
  byte[] outputBytes = cipher.doFinal(inputBytes);
  encryptedValue = new BASE64Encoder().encode(outputBytes);
  return encryptedValue;
 }
 public static String decrypt(String encryptedString, String commonKey)
   throws InvalidKeyException, IllegalBlockSizeException,
   BadPaddingException, IOException {
  String decryptedValue = &quot;&quot;;
// When Base64Encoded strings are passed in URLs, &#39;+&#39; character gets converted to space and so we need to reconvert the space to &#39;+&#39; and since encoded string cannot have space in it so we are completely safe.
  encryptedString = encryptedString.replace(&#39; &#39;, &#39;+&#39;);
  SecretKey key = getSecretKey(commonKey);
  cipher.init(Cipher.DECRYPT_MODE, key);
  byte[] recoveredBytes = cipher.doFinal(new BASE64Decoder()
    .decodeBuffer(encryptedString));
  decryptedValue = new String(recoveredBytes);
  return decryptedValue;
 }
 private static SecretKey getSecretKey(String secretPassword) {
  SecretKey key = null;
  try {
   cipher = Cipher.getInstance(CRYPTOGRAPHY_ALGO_DES);
   keySpec = new DESKeySpec(secretPassword.getBytes(&quot;UTF8&quot;));
   keyFactory = SecretKeyFactory.getInstance(CRYPTOGRAPHY_ALGO_DES);
   key = keyFactory.generateSecret(keySpec);
  } catch (Exception e) {
   e.printStackTrace();
   System.out.println(&quot;Error in generating the secret Key&quot;);
  }
  return key;
 }
}

&lt;/pre&gt;&lt;b&gt;Download&lt;/b&gt;&lt;br /&gt;
Code can be downloaded from &lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/DESCode.zip&quot;&gt;here&lt;/a&gt;&lt;br /&gt;
Download contains:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Cryptography.java: Contains the encrption and decryption method&lt;/li&gt;
&lt;li&gt;TestCrypto.java&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;b&gt;Related Articles&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://java-espresso.blogspot.com/2011/09/md5-encryption-in-java.html&quot;&gt;Implementing MD5 in java&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Relevant References&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://orlingrabbe.com/des.htm&quot;&gt;DES explained&lt;/a&gt;&lt;br /&gt;
Wiki Links:&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Data_Encryption_Standard&quot;&gt;DES&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Symmetric-key_algorithm&quot;&gt;Symmetric-key algorithm&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Triple_DES&quot;&gt;Triple-DES&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/5628020107732497604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/des-algorithm-code-in-java.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5628020107732497604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/5628020107732497604'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/des-algorithm-code-in-java.html' title='DES algorithm Code in Java'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>13</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-3831304825925850084</id><published>2011-09-14T14:09:00.000-07:00</published><updated>2011-09-27T13:53:59.200-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="crypto"/><category scheme="http://www.blogger.com/atom/ns#" term="cryptography"/><category scheme="http://www.blogger.com/atom/ns#" term="java cryptography"/><category scheme="http://www.blogger.com/atom/ns#" term="java md5"/><category scheme="http://www.blogger.com/atom/ns#" term="java md5 algo"/><category scheme="http://www.blogger.com/atom/ns#" term="java security"/><category scheme="http://www.blogger.com/atom/ns#" term="md5 algo java"/><category scheme="http://www.blogger.com/atom/ns#" term="MD5 java"/><category scheme="http://www.blogger.com/atom/ns#" term="security java"/><title type='text'>MD5 encryption in Java</title><content type='html'>&lt;b&gt;What is MD5?&lt;/b&gt;&lt;br /&gt;
MD5(Message-Digest algorithm 5)is hashing function which results in 128 bit(16 byte) hash value. It came as a replacement of MD4 which was considered insecure then. MD5 is one way encryption technique means once I have encrypted some text using MD5 I cannot get the clear text from the hash value again. But now it is proved that even MD5 is vulnerable.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Where can we use MD5?&lt;/b&gt;&lt;br /&gt;
MD5 can primarily be used for encryption and for checking file integrity. But again remember it is possible to have two big different files having same hash value.&lt;br /&gt;
Usage examples:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Data Encryption:You can use it to encrypt your passwords something like getMD5Hash(password+date+time of registration)= &#39;hashed value&#39;. Here we have concatenated actual passwords with date and time of registration to ensure that every time a unique hash value gets generated.&lt;/li&gt;
&lt;li&gt;File integrity: Suppose you want to make a file comparing utility. So if you will go straight away and compare the files it will not efficient. So first we can compare size, then HASH VALUE OF BOTH FILES(by using MD5 hashing) and if both are same then probably you can compare the actual text in the files.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;b&gt;Implementing MD5 in Java:&lt;/b&gt;&lt;br /&gt;
MD5 is already implemented in java. So we just need to reuse the method and do some pre and post processing. MD5 hashing technique always produces a fixed length encrypted string having 128 bits or 16 bytes and so you will always get a hexadecimal string of length 16.&lt;br /&gt;
Code listing is given below:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Formatter;

/**
 * @author dharmvir.singh
 * @Description: This class generated the hash code of few strings
 * 
 */
public class TestMD5 {
 public static void main(String[] args) {
  String[] inputStrings = { &quot;Open Source&quot;, &quot;Apache project&quot;,
    &quot;java espresso&quot; };
  System.out.println(&quot;String\t\t\tHash Value\t\tHash val length&quot;);
  System.out.println(&quot;======\t\t\t==========\t\t===============&quot;);
  for (int i = 0; i &lt; inputStrings.length; i++) {
   System.out.println(inputStrings[i] + &quot;\t\t&quot;
     + getMD5HashVal(inputStrings[i]));
  }
 }

 public static String getMD5HashVal(String strToBeEncrypted) {
  String encryptedString = null;
  byte[] bytesToBeEncrypted;
  try {
   // convert string to bytes using a encoding scheme
   bytesToBeEncrypted = strToBeEncrypted.getBytes(&quot;UTF-8&quot;);
   MessageDigest md = MessageDigest.getInstance(&quot;MD5&quot;);
   byte[] theDigest = md.digest(bytesToBeEncrypted);
                        // convert each byte to a hexadecimal digit
   Formatter formatter = new Formatter();
   for (byte b : theDigest) {
    formatter.format(&quot;%02x&quot;, b);
   }
   encryptedString = formatter.toString().toLowerCase();

  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  } catch (NoSuchAlgorithmException e) {
   e.printStackTrace();
  }
  return encryptedString;
 }
}
&lt;/pre&gt;
The code is self explanatory and I tested it already. 

For production purposes, avoid using MD5 as encryption technique for banking domain and (security concerned) domains.
&lt;br/&gt;
&lt;b&gt;Related Articles&lt;/b&gt;
&lt;br/&gt;
&lt;a href=&quot;http://java-espresso.blogspot.com/2011/09/des-algorithm-code-in-java.html&quot;&gt;Implementing DES in Java&lt;/a&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Relevant References&lt;/b&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/MD5&quot;&gt;Wiki-MD5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://download.oracle.com/javase/1.4.2/docs/api/java/security/MessageDigest.html&quot;&gt;java.security.MessageDigest-docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a imageanchor=&quot;1&quot; target=&quot;_blank&quot;  href=&quot;http://www.amazon.com/JBuilder-Professional-Development-Integrated-Database/dp/B003HOU808?ie=UTF8&amp;tag=widgetsamazon-20&amp;link_code=bil&amp;camp=213689&amp;creative=392969&quot;&gt;&lt;img alt=&quot;JBuilder Professional: Pure Java Visual Development With Integrated Database Tools&quot; src=&quot;http://ws.amazon.com/widgets/q?MarketPlace=US&amp;ServiceVersion=20070822&amp;ID=AsinImage&amp;WS=1&amp;Format=_SL160_&amp;ASIN=B003HOU808&amp;tag=widgetsamazon-20&quot; /&gt;&lt;/a&gt;&lt;img src=&quot;http://www.assoc-amazon.com/e/ir?t=widgetsamazon-20&amp;l=bil&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=B003HOU808&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important; padding: 0px !important&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/3831304825925850084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/md5-encryption-in-java.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3831304825925850084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3831304825925850084'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/md5-encryption-in-java.html' title='MD5 encryption in Java'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-4794466813239776599.post-3345333508869325034</id><published>2011-09-13T08:36:00.001-07:00</published><updated>2012-02-23T04:10:41.168-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="NetBeans RA layer request failed"/><category scheme="http://www.blogger.com/atom/ns#" term="org.tigris.subversion.javahl.ClientException"/><category scheme="http://www.blogger.com/atom/ns#" term="org.tigris.subversion.javahl.ClientException: RA layer request failed"/><category scheme="http://www.blogger.com/atom/ns#" term="RA layer request failed"/><category scheme="http://www.blogger.com/atom/ns#" term="subversion.javahl"/><title type='text'>org.tigris.subversion.javahl.ClientException: RA layer request failed</title><content type='html'>Title of the article is basically an error which you might receive when you are trying to connect to a SVN repository over internet (that means repository is outside your corporate LAN firewall) using subversion plugin (inside Eclipse).&lt;br /&gt;
Below is the screen-shot of the same:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/RA_layer_req_failed.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;194&quot; width=&quot;400&quot; src=&quot;https://sites.google.com/site/blogblunder/java-espresso/RA_layer_req_failed.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Now how to resolve it. Here we go:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Close the eclipse if it is running.&lt;/li&gt;
&lt;li&gt;Open the following file: &lt;br /&gt;
Windows Vista/7: C:\Users\&amp;lt;user-profile-name&amp;gt;\AppData\Roaming\Subversion\server&lt;br /&gt;
Windows XP: C:\Documents and Settings\&amp;lt;user-profile-name&amp;gt;\Application Data\Subversion\server&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Go to the Entry shown below:&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
#http-proxy-host = somehost.example.com
#http-proxy-port = 80
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword
&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Uncomment the http-proxy-host and http-proxy-port line and provide your proxy server path and port no. Do not leave any spaces before the http-proxy-host.So it should look like this:&lt;pre name=&quot;code&quot; class=&quot;java&quot;&gt;http-proxy-host = substitute with your proxy server path
http-proxy-port = substitute your proxy server port
&lt;/pre&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Start the eclipse again.&lt;/li&gt;
That should resolve the problem for you. If this article resolves your problem. Please leave a comment otherwise add comment to let me know, your issue. &lt;/ol&gt;&lt;br /&gt;
After seeing so many comments, I decided that I will try the same thing for NetBeans and guess what it was easier than eclipse also.&lt;br /&gt;
Following are the steps to access the SVN behind the firewall:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt; Click on Team &amp;gt; select subversion &amp;gt; select checkout...&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/NetBeans_checkout.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;194&quot; width=&quot;400&quot;  src=&quot;https://sites.google.com/site/blogblunder/java-espresso/NetBeans_checkout.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;i&gt;Click on the image to open it in new window to see it properly.&lt;/i&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt; On the next window fill the repository URL, username and password as shown:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/NetBeans_SVN_connection.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;194&quot; width=&quot;400&quot; src=&quot;https://sites.google.com/site/blogblunder/java-espresso/NetBeans_SVN_connection.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt; After that click on &lt;i&gt;Proxy Configuration..&lt;/i&gt; button and select Manual Proxy settings and fill the proxy server host and port and click on &lt;i&gt;ok&lt;/i&gt; as shown:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/blogblunder/java-espresso/NetBeans_Proxy_Config.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;194&quot; width=&quot;400&quot; src=&quot;https://sites.google.com/site/blogblunder/java-espresso/NetBeans_Proxy_Config.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;i&gt;&lt;b&gt;Note: If your company uses a .pac file for proxy settings then open that file and find out the proper proxy server address and port number. In NetBeans do not select the option of using system proxy settings&lt;/b&gt;&lt;/i&gt;

&lt;/ol&gt;At times we make mistake in entering the URL itself so here is a sample SVN url&lt;br /&gt;
https://onlinerepository.com/svn/myproject</content><link rel='replies' type='application/atom+xml' href='http://java-espresso.blogspot.com/feeds/3345333508869325034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://java-espresso.blogspot.com/2011/09/orgtigrissubversionjavahlclientexceptio.html#comment-form' title='30 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3345333508869325034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4794466813239776599/posts/default/3345333508869325034'/><link rel='alternate' type='text/html' href='http://java-espresso.blogspot.com/2011/09/orgtigrissubversionjavahlclientexceptio.html' title='org.tigris.subversion.javahl.ClientException: RA layer request failed'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05823921645971746143</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>30</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry></feed>