<?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-4782826355872180571</id><updated>2025-11-04T03:21:39.443-08:00</updated><category term="basics"/><category term="Java SE"/><category term="Eclipse"/><category term="Google Code"/><category term="JSP"/><category term="SVN"/><category term="Subversion"/><category term="error handling"/><category term="html"/><title type='text'>Beginning Java</title><subtitle type='html'>Sharing experiences about Java</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4782826355872180571.post-4520435288261668452</id><published>2012-05-29T18:27:00.003-07:00</published><updated>2012-05-29T18:28:13.683-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="basics"/><title type='text'>Java API</title><content type='html'>Hi guys&lt;br /&gt;
&lt;br /&gt;
API is an&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Acronym_and_initialism&quot; style=&quot;background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 19px; text-align: center; text-decoration: none;&quot; title=&quot;Acronym and initialism&quot;&gt;acronym&lt;/a&gt;&amp;nbsp;for&amp;nbsp;Application Programming Interface, which is a set of libraries that we may use when we are coding our own Java programs.&lt;br /&gt;
&lt;br /&gt;
There are three kinds of Java APIs:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Core Java API&lt;/b&gt;&lt;br /&gt;
The oficial Java API.&amp;nbsp;Please take a look at the Java API docs at Oracle website:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.oracle.com/javase/6/docs/api/&quot;&gt;http://docs.oracle.com/javase/6/docs/api/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;JSR - Java Specification Request&lt;/b&gt;&lt;br /&gt;
The JCP (Java Community Process) defines specifications in order to extend Java functionallity. Any vendor may develop an API according to a JSR and we can download their libraries and use in our own code.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Third party APIs&lt;/b&gt;&lt;br /&gt;
Other kind of libraries developed to extend Java functionallity, but not related to a JSR.</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/4520435288261668452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2012/05/java-api.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/4520435288261668452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/4520435288261668452'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2012/05/java-api.html' title='Java API'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-4951292588804195529</id><published>2010-12-03T13:35:00.000-08:00</published><updated>2010-12-03T13:42:14.643-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java SE"/><title type='text'>Formatting Dates</title><content type='html'>It&#39;s very easy to use the SimpleDateFormat from the java.text API to format a date variable:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;Date currentDate = new Date();
SimpleDateFormat formatter = 
     new SimpleDateFormat(&quot;yyyy/MM/dd&quot;);

System.out.println(&quot;Date without any format: &quot;
     + currentDate);

System.out.println(&quot;Our beautiful formatted date: &quot;
     + formatter.format(currentDate));
&lt;/pre&gt;&lt;br /&gt;
Explaining the code:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;First we instantiated a variable called currentDate using the default constructor of the java.util.Date class, which creates a Date object with the value as the current date and time&lt;/li&gt;
&lt;li&gt;Then we got a instance of the SimpleDateFormat class, specifying the pattern &quot;yyyy/MM/dd&quot; which means year with four digits, month with two digits (01 to 12) and day of the month with two digits (01 to 31).&lt;/li&gt;
&lt;li&gt;We displayed on the console the currentDate variable (we used the default toString() method to display the&amp;nbsp;variable&amp;nbsp;value)&lt;/li&gt;
&lt;li&gt;Then we displayed the formatted value using the method format of the SimpleDateFormat class&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
You may find more information at:&lt;br /&gt;
&lt;a href=&quot;http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html&quot;&gt;http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/4951292588804195529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/12/formatting-dates.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/4951292588804195529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/4951292588804195529'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/12/formatting-dates.html' title='Formatting Dates'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-6364109852688374898</id><published>2010-12-03T13:24:00.000-08:00</published><updated>2010-12-03T13:24:52.487-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="basics"/><title type='text'>What’s the difference between JDK and JRE?</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span lang=&quot;EN&quot;&gt;While the Java Runtime Environment (JRE) is a set of libraries and programs which enables the final user to run Java applications, t&lt;/span&gt;he&amp;nbsp;Java Development Kit&amp;nbsp;(JDK) is a&amp;nbsp;product aimed at&amp;nbsp;Java&amp;nbsp;developers.&amp;nbsp;With the JDK we are able to develop, debug and run a Java application on any platform.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span lang=&quot;EN&quot;&gt;The JDK has a lot of components, but the main are:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;span&gt;&lt;span style=&quot;font: normal normal normal 7pt/normal &#39;Times New Roman&#39;;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN&quot;&gt;&lt;b&gt;javac&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span lang=&quot;EN&quot;&gt;&lt;/span&gt;A compiler which converts source code (text files with extension .java) to a bytecode file (mainly .class files)&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span lang=&quot;EN&quot;&gt;&lt;b&gt;java&lt;/b&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;It´s the loader for Java applications. It interprets the bytecode file generated by javac compiler to the operational system.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px;&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/6364109852688374898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-difference-between-jdk-and-jre.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/6364109852688374898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/6364109852688374898'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-difference-between-jdk-and-jre.html' title='What’s the difference between JDK and JRE?'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-7578530191515616060</id><published>2010-12-03T13:16:00.000-08:00</published><updated>2010-12-03T13:16:17.077-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="basics"/><title type='text'>What`s the difference between JSE, JME and JEE?</title><content type='html'>Java is a program language that enables the development on many platforms. It´s possible to run Java programs on small devices (like mobile phones), on personal computers and even on mainframes. To be able to do that Java has three development environments: JSE, JME and JEE.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;&lt;b&gt;JSE – Java Standard Edition&lt;/b&gt;&lt;br /&gt;
Java Platform, Standard Edition or Java SE is a widely used platform for programming in the Java language. It is the Java Platform used to deploy portable applications for general use. In practical terms, Java SE consists of a virtual machine, which must be used to run Java programs, together with a set of libraries (or &quot;packages&quot;) needed to allow the use of file systems, networks, graphical interfaces, and so on, from within those programs.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
The other two environments (JME and JEE) are based on JSE.&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;b&gt;JME – Java Micro Edition&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Java Platform, Micro Edition, or Java ME, is a Java platform designed for embedded systems (mobile devices are one kind of such systems) . Target devices range from industrial controls to mobile phones (especially feature phones) and set-top boxes.&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;b&gt;JEE – Java Enterprise Edition&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The Java platform Enterprise Edition differs from the Java Standard Edition Platform (JSE) in that it adds libraries which provide functionality to deploy fault-tolerant, distributed, multi-tier Java software, based largely on modular components running on an application server.&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
More information at:&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Java_Platform,_Standard_Edition&quot;&gt;http://en.wikipedia.org/wiki/Java_Platform,_Standard_Edition&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Java_Platform,_Micro_Edition&quot;&gt;http://en.wikipedia.org/wiki/Java_Platform,_Micro_Edition&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.oracle.com/technetwork/java/javaee/overview/index.html&quot;&gt;http://www.oracle.com/technetwork/java/javaee/overview/index.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition&quot;&gt;http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/7578530191515616060/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-difference-between-jse-jme-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/7578530191515616060'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/7578530191515616060'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-difference-between-jse-jme-and.html' title='What`s the difference between JSE, JME and JEE?'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-452590653745808365</id><published>2010-12-02T14:36:00.000-08:00</published><updated>2010-12-02T14:36:09.034-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="basics"/><title type='text'>What&#39;s the JVM?</title><content type='html'>JVM means Java Virtual Machine which is the environment where we run computer programs written in Java language.&amp;nbsp;Java was conceived with the concept of WORA: &quot;write once, run anywhere&quot;. This is done using the Java Virtual Machine.&lt;br /&gt;
&lt;br /&gt;
A Java program is compiled into a standardized portable binary format (a bytecode file), which typically comes in the form of .class files. The JVM executes the .class files, interpreting the commands to the operational systems.&lt;br /&gt;
&lt;br /&gt;
You may find more info at:&lt;div&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Java_Virtual_Machine&quot;&gt;http://en.wikipedia.org/wiki/Java_Virtual_Machine&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/452590653745808365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-jvm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/452590653745808365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/452590653745808365'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-jvm.html' title='What&#39;s the JVM?'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-578955326103803153</id><published>2010-12-02T14:03:00.000-08:00</published><updated>2010-12-02T14:05:25.609-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="basics"/><title type='text'>What&#39;s Java?</title><content type='html'>&lt;div&gt;So, what&#39;s Java?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;According to Wikipedia:&lt;/div&gt;&lt;blockquote&gt;Java is a programming language originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems&#39; Java platform. The language derives much of its syntax from Cand C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers &quot;write once, run anywhere&quot;. Java is currently one of the most popular programming languages in use, and is widely used from application software to web applications.&lt;/blockquote&gt;&lt;div&gt;Basically, Java is a object-oriented programming language that runs over a virtual machine. The Java Virtual Machine (JVM) enables our programs to run under almost all operational systems on any platform, from desktops to television sets.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;You may find more information at:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Java_(programming_language)&quot;&gt;Wikypedia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/docs/white/langenv/index.html&quot;&gt;Java Sun/Oracle web site: The Java Language Environment&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/578955326103803153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/578955326103803153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/578955326103803153'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/12/whats-java.html' title='What&#39;s Java?'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-1456893327864648042</id><published>2010-11-29T12:19:00.000-08:00</published><updated>2010-11-29T12:19:31.475-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="basics"/><category scheme="http://www.blogger.com/atom/ns#" term="Java SE"/><title type='text'>Formatting numbers</title><content type='html'>It´s possible format numbers and dates using the java.text API.&lt;br /&gt;
&lt;br /&gt;
Formatting a number is pretty simple. We use the DecimalFormat class to specify a custom format:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;NumberFormat formatter1 = new DecimalFormat(&quot;#,###&quot;);
System.out.println(formatter1.format(123123))  // displays 123,123

NumberFormat formatter2 = new DecimalFormat(&quot;0.00&quot;);
System.out.println(formatter2.format(123123))  // displays 123123.00

NumberFormat formatter3 = new DecimalFormat(&quot;#,##0.00&quot;);
System.out.println(formatter3.format(123123.123))  // displays 123,123.12
&lt;/pre&gt;&lt;br /&gt;
There are a lot of patterns you could use to format numbers.&lt;br /&gt;
Just take a look at &lt;a href=&quot;http://download.oracle.com/javase/tutorial/i18n/format/decimalFormat.html&quot;&gt;http://download.oracle.com/javase/tutorial/i18n/format/decimalFormat.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/1456893327864648042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/11/formatting-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/1456893327864648042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/1456893327864648042'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/11/formatting-numbers.html' title='Formatting numbers'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-8558409396085857368</id><published>2010-11-28T14:04:00.000-08:00</published><updated>2010-11-28T14:04:28.147-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="error handling"/><category scheme="http://www.blogger.com/atom/ns#" term="html"/><category scheme="http://www.blogger.com/atom/ns#" term="JSP"/><title type='text'>Configuring a JSP error page</title><content type='html'>Hi guys.&lt;br /&gt;
&lt;br /&gt;
It&#39;s awful to visit a web site and receive an error page that does not explain what the hell had happened. However it&#39;s very easy to configure a nice error page to be shown when an unexpected error happens.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1) Create a new JSP page, with the follow code:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;lt;%@ page isErrorPage=&quot;true&quot; import=&quot;java.io.*&quot; %&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;Error Page&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;

    &amp;lt;body&amp;gt;
        &amp;lt;h2&amp;gt;Unexpected error&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&amp;lt;%= exception.toString() %&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;&amp;lt;%=
            StringWriter sw = new StringWriter(); 
            PrintWriter pw = new PrintWriter(sw); 
            exception.printStackTrace(pw); 
            out.print(sw); 
            sw.close(); 
            pw.close();
        &amp;lt;/p&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;strong&gt;Explaining the code:&lt;/strong&gt;&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The attribute errorPage=true identifies the JSP page as an error page&lt;/li&gt;
&lt;li&gt;As an errorPage, an object called &quot;exception&quot; is made available. Its type is &lt;a href=&quot;http://download.oracle.com/javase/6/docs/api/java/lang/Throwable.html&quot;&gt;java.lang.Throwable&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;We used the&amp;nbsp;method exception.toString() to return&amp;nbsp;a description of the&amp;nbsp;exception&lt;/li&gt;
&lt;li&gt;We also used the method exception.printStackTrace to give more information about what happened&lt;/li&gt;
&lt;/ul&gt;There are a lot of other usefull information that you may use in this error page. Just take a look at the &lt;a href=&quot;http://download.oracle.com/javase/6/docs/api/java/lang/Throwable.html&quot;&gt;java.lang.Throwable&lt;/a&gt; class.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2) Configure the application&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Now that we have our error page, let&#39;s configure the application to call it when an unexpected exception happens.&amp;nbsp;There are two ways to do that:&lt;br /&gt;
&lt;br /&gt;
2a) Configure each JSP page to call the error page when an unexpected exception happens.&lt;br /&gt;
&lt;br /&gt;
Include the attribute errorPage on the top of the page code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;lt;%@ page errorPage=&quot;errorPage.jsp&quot; %&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
2b) Configure the web.xml file to call the error page for the entire application&lt;br /&gt;
&lt;br /&gt;
Use the tag error-page to configure a JSP page to be called according to the error code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;lt;error-page&amp;gt;
    &amp;lt;error-code&amp;gt;500&amp;lt;/error-code&amp;gt;
    &amp;lt;location&amp;gt;errorPage.jsp&amp;lt;/location&amp;gt;
&amp;lt;/error-page&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Explaining the code:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The tag error-page tells the application server what to do when an error happens&lt;/li&gt;
&lt;li&gt;The tag error-code specifies what error should be catch&lt;/li&gt;
&lt;li&gt;The tag location specifies what page will be show when the error happens&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Some common error codes are:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;404 - Page not found&lt;/li&gt;
&lt;li&gt;500 - Application error (exception)&lt;/li&gt;
&lt;li&gt;You may find other code descriptions at &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html&quot;&gt;this link&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;That&#39;s it! Now your application has a beautiful and&amp;nbsp;useful&amp;nbsp;error page.&lt;/div&gt;&lt;br /&gt;
&lt;pre&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/8558409396085857368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/11/configuring-jsp-error-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/8558409396085857368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/8558409396085857368'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/11/configuring-jsp-error-page.html' title='Configuring a JSP error page'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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-4782826355872180571.post-8557971918601854700</id><published>2010-11-23T17:09:00.000-08:00</published><updated>2010-11-23T17:18:37.817-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="Google Code"/><category scheme="http://www.blogger.com/atom/ns#" term="Subversion"/><category scheme="http://www.blogger.com/atom/ns#" term="SVN"/><title type='text'>Using Google Code as a project repository</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Hi guys.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;What about using a free SVN host? And what about a Google one?&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;It&#39;s very easy to configure your project in Google Code SVN service. Just follow this steps (I&#39;m using Eclipse Helios):&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;First you must create your project at &lt;/span&gt;&lt;a href=&quot;http://code.google.com/hosting/&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Google Code&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Then install&amp;nbsp;&lt;a href=&quot;http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Subversion&lt;/span&gt;&lt;/a&gt;&amp;nbsp;according to your Eclipse version.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now you are able to share your project. Just open your workspace, right click your project and select:&amp;nbsp;Team &amp;gt; Share Project&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;A new window will appear asking for a repository type. Just select &quot;SVN&quot; and click next.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Select &quot;Create a new repository location&quot; and click next&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Enter your project URL (something like&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;https://yourproject.googlecode.com/svn) and click next&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Select the option &quot;Use project name as folder name&quot; and click next&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Insert a comment (or just let the default one) and click finish&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Eclipse will ask to change to the Team Synchronizing perspective. Click yes.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Right click your project in the Synchronize window and select: Commit...&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Insert a comment and click finish&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;Ok. Your project has just been shared.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;Just a tip:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;In order to check out your project, y&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;ou must have a Google Code password. It&#39;s different from your Google account. You may find it at&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; text-decoration: underline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;&lt;a href=&quot;http://code.google.com/hosting/settings&quot; style=&quot;text-decoration: underline;&quot;&gt;http://code.google.com/hosting/settings&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 20px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; text-decoration: underline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://beginning-java.blogspot.com/feeds/8557971918601854700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://beginning-java.blogspot.com/2010/11/using-google-code-as-repository.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/8557971918601854700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4782826355872180571/posts/default/8557971918601854700'/><link rel='alternate' type='text/html' href='http://beginning-java.blogspot.com/2010/11/using-google-code-as-repository.html' title='Using Google Code as a project repository'/><author><name>André Alves</name><uri>http://www.blogger.com/profile/05262759052357808417</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></feed>