<?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: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-2083400580050165811</id><updated>2012-01-23T13:41:09.528Z</updated><category term='Python'/><category term='Mockito'/><category term='byte code engineering library'/><category term='Expression Language'/><category term='jaxb'/><category term='C'/><category term='x86'/><category term='hexadecimal'/><category term='assembler'/><category term='about'/><category term='XMLBeans'/><category term='C++'/><category term='exceptions'/><category term='bytecode'/><category term='Scala'/><category term='JRuby'/><category term='WebSEAL'/><category term='mutex'/><category term='websphere'/><category term='Jython'/><category term='eclipse'/><category term='JUnit'/><category term='basics'/><category term='jax-ws'/><category term='NASM'/><category term='URLs'/><category term='Unified Expression Language'/><category term='EL'/><category term='i18n'/><category term='JPDA'/><category term='java-ee6'/><category term='ant'/><category term='JUEL'/><category term='jax-rpc'/><category term='soap'/><category term='BCEL'/><category term='wsdl2java'/><category term='synchronization'/><category term='jsp'/><category term='XML'/><category term='streams'/><category term='web services'/><category term='Java'/><category term='concurrency'/><category term='Groovy'/><category term='Hello World'/><category term='rational application developer'/><category term='C#'/><category term='Tomcat'/><category term='XPath'/><category term='Ruby'/><category term='debug.exe'/><category term='JSF'/><category term='iPad'/><category term='j2ee'/><category term='JavaScript'/><category term='subversion'/><category term='dependencies'/><category term='DOS'/><title type='text'>Illegal Argument Exception</title><subtitle type='html'>Miscellaneous Computer Code</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>57</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-7912586046147803521</id><published>2012-01-02T19:38:00.000Z</published><updated>2012-01-02T19:38:08.901Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><category scheme='http://www.blogger.com/atom/ns#' term='JUnit'/><title type='text'>JSF: managed beans without JSF dependencies</title><summary type='text'>A previous
post discussed how to inject the FacesContext into managed
beans using a
broker. This post demonstrates how to build on that approach with
greater levels of abstraction.

It is generally possible to remove direct JSF dependencies from
managed bean code. You might want to do this to reduce coupling,
improve cohesion
or in the interests of writing testable code.

The code was written </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/7912586046147803521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2012/01/jsf-managed-beans-without-jsf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7912586046147803521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7912586046147803521'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2012/01/jsf-managed-beans-without-jsf.html' title='JSF: managed beans without JSF dependencies'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4499934871918092964</id><published>2011-12-27T11:50:00.001Z</published><updated>2011-12-27T15:02:07.844Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><category scheme='http://www.blogger.com/atom/ns#' term='Mockito'/><category scheme='http://www.blogger.com/atom/ns#' term='JUnit'/><title type='text'>JSF: mocking FacesContext for unit tests</title><summary type='text'>Referencing the FacesContext
directly in Java classes makes managed beans more difficult to unit
test. This post discusses how to mock the context for testing outside
the application container.

These examples use Mockito with JUnit. Familiarity with JSF and unit
testing Java is assumed.

I've used the javax.faces.bean annotations but the
techniques apply for other bean management mechanisms (e.g</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4499934871918092964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/12/jsf-mocking-facescontext-for-unit-tests.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4499934871918092964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4499934871918092964'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/12/jsf-mocking-facescontext-for-unit-tests.html' title='JSF: mocking FacesContext for unit tests'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4726171773859955083</id><published>2011-11-27T12:48:00.003Z</published><updated>2011-11-27T14:47:12.076Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='jsp'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><category scheme='http://www.blogger.com/atom/ns#' term='j2ee'/><title type='text'>JSP: arbitrary attributes on JSF controls</title><summary type='text'>One criticism developers have of JavaServer Faces is that it is
not possible to add arbitrary attributes to the resultant markup.
Problems arise when they wish to add custom attributes specific to
JavaScript frameworks (e.g. dojoType for the Dojo toolkit)
or HTML 5 attributes (such as data- or placeholder.)

However, this is not a technical limitation of the JSF framework;
only a limitation of </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4726171773859955083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/11/jsp-arbitrary-attributes-on-jsf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4726171773859955083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4726171773859955083'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/11/jsp-arbitrary-attributes-on-jsf.html' title='JSP: arbitrary attributes on JSF controls'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2038395085675532011</id><published>2011-10-27T21:09:00.002+01:00</published><updated>2011-10-27T21:16:29.931+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='websphere'/><category scheme='http://www.blogger.com/atom/ns#' term='jax-rpc'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='rational application developer'/><category scheme='http://www.blogger.com/atom/ns#' term='wsdl2java'/><category scheme='http://www.blogger.com/atom/ns#' term='soap'/><category scheme='http://www.blogger.com/atom/ns#' term='web services'/><category scheme='http://www.blogger.com/atom/ns#' term='ant'/><title type='text'>WebSphere AS: RAD vs WSDL2Java for JAX-RPC client SOAP bindings</title><summary type='text'>I've been doing a bit of work recently with JAX-RPC on WebSphere Application Server 6.1.
This is hardly cutting edge software (WAS 8 is out; JAX-RPC has been superceded by JAX-WS) but platforms can have a long shelf-life in the enterprise.

This post describes how to migrate from client bindings developed using RAD to automated generation via Ant.
JAX-RPC isn't restricted to consuming SOAP in </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2038395085675532011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/10/websphere-as-rad-vs-wsdl2java-for-jax.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2038395085675532011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2038395085675532011'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/10/websphere-as-rad-vs-wsdl2java-for-jax.html' title='WebSphere AS: RAD vs WSDL2Java for JAX-RPC client SOAP bindings'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-9065231851713900120</id><published>2011-04-23T16:46:00.002+01:00</published><updated>2011-04-23T16:48:55.838+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='jax-ws'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='soap'/><category scheme='http://www.blogger.com/atom/ns#' term='web services'/><category scheme='http://www.blogger.com/atom/ns#' term='jaxb'/><category scheme='http://www.blogger.com/atom/ns#' term='java-ee6'/><title type='text'>Java: JAX-WS web services and clients</title><summary type='text'>JAX-WS is built into Java 6. This makes it a low-dependency
choice for writing SOAP-based web service code. This post covers the
basics of JAX-WS development with a sample web service.

An understanding of the following is beneficial: Servlets; XML
Schema Definition (XSD); Web Services Description Langauge (WSDL);
XPath; JAXB.

Server code was tested on Glassfish 3; client code was tested on
Java</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/9065231851713900120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/04/java-jax-ws-web-services-and-clients.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/9065231851713900120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/9065231851713900120'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/04/java-jax-ws-web-services-and-clients.html' title='Java: JAX-WS web services and clients'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-8745431808199781350</id><published>2011-01-22T15:17:00.000Z</published><updated>2011-01-22T15:17:12.303Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPad'/><category scheme='http://www.blogger.com/atom/ns#' term='WebSEAL'/><title type='text'>TAM WebSEAL: authentication and the iPad</title><summary type='text'>After upgrading the iPads to a new version, we started seeing a
logon issue with servers protected by TAM
WebSEAL. After successfully authenticating, users were redirected to the
resource apple-touch-icon.png which resulted in a 404 "Not Found" error.



Configuring WebSEAL

The problem turned out to be related to the favicon.ico
issue in Firefox:

In a protected WebSEAL environment, Firefox's
</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/8745431808199781350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/01/tam-webseal-authentication-and-ipad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8745431808199781350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8745431808199781350'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2011/01/tam-webseal-authentication-and-ipad.html' title='TAM WebSEAL: authentication and the iPad'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-1412822218849389573</id><published>2010-12-24T21:46:00.001Z</published><updated>2010-12-26T14:24:13.758Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>JavaScript: validating UTF-8 string lengths in the browser</title><summary type='text'>Let's take a JavaScript string: "€100". This
is going to be sent from a browser input box and stored in a web
server's database. The database is using the UTF-8 encoding and the
constraint on the column is CHAR(4). Spot the problem?



From the ECMA specification:

When a String contains actual textual data,
each element is considered to be a single UTF-16 code unit.

As a UTF-16
string, this </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/1412822218849389573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/12/javascript-validating-utf-8-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1412822218849389573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1412822218849389573'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/12/javascript-validating-utf-8-string.html' title='JavaScript: validating UTF-8 string lengths in the browser'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4031248658575475111</id><published>2010-12-19T17:39:00.000Z</published><updated>2010-12-19T17:39:32.514Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='jsp'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>JSP: what all the encoding declarations mean</title><summary type='text'>When you see a JSP document, you might wonder why it specifies
the UTF-8 encoding three or four times. This is a post about what those
declarations mean.



A sample JSP document

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4031248658575475111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/12/jsp-what-all-encoding-declarations-mean.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4031248658575475111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4031248658575475111'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/12/jsp-what-all-encoding-declarations-mean.html' title='JSP: what all the encoding declarations mean'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-1658132443702976434</id><published>2010-11-21T14:09:00.000Z</published><updated>2010-11-21T14:09:04.605Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='about'/><title type='text'>Comments policy</title><summary type='text'>Comments are moderated and will not appear until I approve them.


 I don't live on the blog, so it may take me some time to see and respond to your comment.
 I won't publish comments with e-mail addresses in them.
 If you post a question and I don't respond, I just may not know the answer off the top of my head and may not feel like putting in the research to answer it. You'll have more luck on </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/1658132443702976434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/11/comments-policy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1658132443702976434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1658132443702976434'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/11/comments-policy.html' title='Comments policy'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-241669866253948098</id><published>2010-09-19T16:56:00.002+01:00</published><updated>2011-10-27T21:14:35.940+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><title type='text'>Java: System.console(), IDEs and testing</title><summary type='text'>The method System.console()
can return null if there is no console device present. This
comes as a surprise to people when they run
their code in an IDE. This post is about overcoming such problems.



Is it worth using java.io.Console at all?

The Console
class in Java 6 has the following constraints:


  It is final, so you can't provide your own
  implementation directly
  There is no service </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/241669866253948098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/09/java-systemconsole-ides-and-testing.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/241669866253948098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/241669866253948098'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/09/java-systemconsole-ides-and-testing.html' title='Java: System.console(), IDEs and testing'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3358826396517983040</id><published>2010-09-16T23:16:00.001+01:00</published><updated>2010-09-16T23:17:27.185+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Java: "Content is not allowed in prolog" - causes of this XML processing error</title><summary type='text'>Content is not allowed in prolog is an error generally
emitted by the Java XML parsers when data is encountered before the &lt;?xml...
declaration. You may inspect the document in a text editor and think
nothing is wrong, but you need to go down to the byte level to understand
the problem. You probably have a character encoding bug.



This code reproduces the problem:


  
     import java.io.*;
</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3358826396517983040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/09/java-content-is-not-allowed-in-prolog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3358826396517983040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3358826396517983040'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/09/java-content-is-not-allowed-in-prolog.html' title='Java: &quot;Content is not allowed in prolog&quot; - causes of this XML processing error'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3844541962556045795</id><published>2010-08-01T16:52:00.002+01:00</published><updated>2010-08-01T16:52:53.123+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java: a fluent I/O API (4/4)</title><summary type='text'>This is the fourth post about my experiments with a fluent I/O
API. This post covers conclusions and limitations of the implementation.
You can find downloads and source repository details further down the
page.



Conclusions

In my first post, I outlined some of the goals of the API. Here's
a run down of how the API measures up.

Goal: reduce the amount of code required for I/O operations

In </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3844541962556045795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-44.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3844541962556045795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3844541962556045795'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-44.html' title='Java: a fluent I/O API (4/4)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-5559225271909559185</id><published>2010-08-01T16:16:00.001+01:00</published><updated>2010-08-01T16:55:59.861+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java: a fluent I/O API (3/4)</title><summary type='text'>This is the third post about my experiments with a fluent I/O
API. This post covers how the API enhances exception handling.



Eliminating unnecessary catch blocks

This code compresses a string into an array of bytes:


  
       private static byte[] gzip(String data) {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        try {
          OutputStream gzip = new </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/5559225271909559185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-34.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5559225271909559185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5559225271909559185'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-34.html' title='Java: a fluent I/O API (3/4)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2451101566533657542</id><published>2010-08-01T16:15:00.001+01:00</published><updated>2010-08-01T16:58:15.938+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java: a fluent I/O API (2/4)</title><summary type='text'>This is the second post about my experiments with a fluent I/O
API. This post covers how to extend the API.



Doctoring streams

Let's look at some of the API's Doctor
implementations. The code uses some static imports to keep things clean:


  
     import static demo.fluentio.Closers.closer;
    import static demo.fluentio.Doctors.DETECT_BOM;
    import static demo.fluentio.Doctors.bom;
    </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2451101566533657542/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-24.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2451101566533657542'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2451101566533657542'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-24.html' title='Java: a fluent I/O API (2/4)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-8140746377758199804</id><published>2010-08-01T15:46:00.001+01:00</published><updated>2010-08-01T17:00:33.754+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java: a fluent I/O API (1/4)</title><summary type='text'>I've been experimenting with fluent API design. You can find the
sources in part
4.

I've often been frustrated with the verbosity of Java I/O.
Handling close with decorators got better with the introduction of the Closeable
interface, but there's still a bit of boilerplate. This post describes a
new fluent API to wrapper around the existing I/O API.



Goals

The goals of this API are:


  </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/8140746377758199804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-14.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8140746377758199804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8140746377758199804'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/08/java-fluent-io-api-14.html' title='Java: a fluent I/O API (1/4)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2545654704927684119</id><published>2010-04-17T19:30:00.000+01:00</published><updated>2010-04-17T19:30:31.731+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>I18N: comparing character encoding in C, C#, Java, Python and Ruby</title><summary type='text'>Don't assume that the character handling conventions you've
learnt in one language/platform will automatically apply in others. I've
selected a cross-section of popular languages to contrast the different
ways character encoding is handled.



Topics


  Character data types
  Transcoding
  C
  C#
  Java
  Python
  Ruby
  Notes
  Resources


Character data types

Character data is always going to</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2545654704927684119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/04/i18n-comparing-character-encoding-in-c.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2545654704927684119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2545654704927684119'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/04/i18n-comparing-character-encoding-in-c.html' title='I18N: comparing character encoding in C, C#, Java, Python and Ruby'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-8255227437192889271</id><published>2010-01-12T16:56:00.005Z</published><updated>2010-01-28T14:48:11.085Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scala'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Scala: implementing a "did you mean..?" spelling corrector</title><summary type='text'>I was looking at Scala again and decided to implement Peter Norvig's algorithm for
suggesting spelling correction suggestions. I suggest you go read How to Write a
Spelling Corrector for the clever stuff.

This implementation is limited to the English alphabet. You'll
need the big.txt file or a
similar set of training data.




  Spell check in Java
  Spell check in Scala
  Did you mean ..?
  </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/8255227437192889271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/01/scala-implementing-did-you-mean.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8255227437192889271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8255227437192889271'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2010/01/scala-implementing-did-you-mean.html' title='Scala: implementing a &quot;did you mean..?&quot; spelling corrector'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3169446701231600443</id><published>2009-12-17T12:49:00.005Z</published><updated>2010-01-28T14:57:29.698Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='URLs'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>Java: safe character handling and URL building</title><summary type='text'>This post discusses HTTP URLs in Java and how to avoid data loss
due to encoding/escaping issues. Special mention is made of the query
part, since it is frequently used to store data.




  Background
  
    Why are there problems?
    Anatomy of a URI
    URIs and HTTP
    HTML query encoding
  
  
  URIs in Java code
  
    The URL class
    The URI class
    URLEncoder and URLDecoder
    A </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3169446701231600443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/12/java-safe-character-handling-and-url.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3169446701231600443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3169446701231600443'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/12/java-safe-character-handling-and-url.html' title='Java: safe character handling and URL building'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_WbSoVuNp3wY/Sx_B0UvLg9I/AAAAAAAAADw/FDZaS9WW2aY/s72-c/encurl.png' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-1090030831808309554</id><published>2009-11-26T12:40:00.003Z</published><updated>2009-11-26T13:00:15.522Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java: application to check binary class versions</title><summary type='text'>

Here's a simple application based on the code from a previous
post. You can run it on .class files, .jar
files or directories (it'll recursively search them for .class
files). It will tell you what version of Java the contained code was
compiled for.

Download: 
javaClassVersionLib_1.1.zip</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/1090030831808309554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/11/java-application-to-check-binary-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1090030831808309554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1090030831808309554'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/11/java-application-to-check-binary-class.html' title='Java: application to check binary class versions'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_WbSoVuNp3wY/Sw53S7UW1JI/AAAAAAAAADo/jl1hggOz-uU/s72-c/scanner.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3632370741147227290</id><published>2009-11-17T23:38:00.004Z</published><updated>2010-01-28T14:59:00.133Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='exceptions'/><title type='text'>Java: how to use an IllegalArgumentException</title><summary type='text'>Calling my web log Illegal Argument Exception seemed
like a clever idea at the time. It is probably just a recipe for
confusing Java neophytes searching for their program errors. I should've
listened to what my granny used to tell me about clarity, precision, and
terseness when choosing identifiers.

To make up for it, here's a short post about IllegalArgumentException
(the exception type).



</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3632370741147227290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/11/java-how-to-use-illegalargumentexceptio.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3632370741147227290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3632370741147227290'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/11/java-how-to-use-illegalargumentexceptio.html' title='Java: how to use an IllegalArgumentException'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-1202003971375299218</id><published>2009-10-09T18:19:00.006+01:00</published><updated>2010-01-28T14:59:47.249Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><title type='text'>JSF: working with component identifiers (id/clientId)</title><summary type='text'>This is a post about how to work with IDs in JavaServer Faces.
You may find this useful if you want to use JavaScript with JSF.


Example ID developer sets on a JSF component:  foo1
What JSF might render in the resultant HTML:   j_id_jsp_115874224_691:table1:0:foo1


This is a revised version of JSF:
working with component IDs (id vs clientId), though you don't need to
read that. This post fixes </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/1202003971375299218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/10/jsf-working-with-component-identifiers.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1202003971375299218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1202003971375299218'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/10/jsf-working-with-component-identifiers.html' title='JSF: working with component identifiers (id/clientId)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_WbSoVuNp3wY/Stn4bomgs4I/AAAAAAAAAB0/SybdFOXtQ0Y/s72-c/table.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-5617115285406159760</id><published>2009-09-18T21:41:00.001+01:00</published><updated>2009-09-18T21:48:22.008+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>Java: character inspector application</title><summary type='text'>

This is a small application that's useful for solving character
encoding bugs. If you've ever wanted to find out exactly what characters
you have, or what bytes they encode to with a specific encoding, this
app may do the trick.

DOWNLOAD
HERE

If you want to know more about character encoding in
Java, read Java:
a rough guide to character encoding.

Sources

All the sources are available in a </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/5617115285406159760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/09/java-character-inspector-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5617115285406159760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5617115285406159760'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/09/java-character-inspector-application.html' title='Java: character inspector application'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_WbSoVuNp3wY/SrPxz8_J2bI/AAAAAAAAABs/jwvQKG_Fl7Q/s72-c/sshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2302642817460096510</id><published>2009-08-01T13:43:00.009+01:00</published><updated>2010-01-28T15:00:22.864Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>JSF: a custom format panel control for localising component layout</title><summary type='text'>This post describes a custom JavaServer
Faces component for controlling the flow layout of controls based on
localised strings.



The h:outputFormat component

The h:outputFormat
control is a standard JSF control for formatting strings. It is often
used with resource bundles.

This is a faces-config.xml declaration for adding
two languages to a JSF application and defining a resource bundle </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2302642817460096510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/08/jsf-custom-format-panel-control-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2302642817460096510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2302642817460096510'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/08/jsf-custom-format-panel-control-for.html' title='JSF: a custom format panel control for localising component layout'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_WbSoVuNp3wY/SnRLow4M3DI/AAAAAAAAABk/Wgr-Qdcvn00/s72-c/outputFormat.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2386069716441453685</id><published>2009-07-22T23:02:00.006+01:00</published><updated>2010-12-11T18:32:42.944Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='bytecode'/><title type='text'>Java: finding class versions</title><summary type='text'>The JVM versions your Java classes will run on is often
determined by how you compile them. Failure to take care with your
classes and dependencies can lead to an UnsupportedClassVersionError.
This post demonstrates how to check your class files.



The class file format

Information on the Java binary format can be found in The Java Virtual
Machine Specification. The ClassFile
Structure defines </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2386069716441453685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/07/java-finding-class-versions.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2386069716441453685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2386069716441453685'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/07/java-finding-class-versions.html' title='Java: finding class versions'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-1431997610105200236</id><published>2009-07-18T14:57:00.002+01:00</published><updated>2010-01-28T15:02:05.995Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>Java: effective Unicode</title><summary type='text'>This is my attempt at a list of maxims to abide by when working
with text in Java, in the vein of Effective Java or
The
Ten Commandments of Unicode. It is also a summary of another
post on character encoding. The list is in no way comprehensive.



1: Understand how UTF-8 differs from ASCII (and CP437,
and Windows-1252, and ISO-8859-1, and ISO-8859-15, and MacRoman, etc.)

Understand how using </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/1431997610105200236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/07/java-effective-unicode.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1431997610105200236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1431997610105200236'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/07/java-effective-unicode.html' title='Java: effective Unicode'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-5033991739319064092</id><published>2009-05-28T11:11:00.003+01:00</published><updated>2011-07-10T14:16:44.027+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XPath'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Java: using XPath with namespaces and implementing NamespaceContext</title><summary type='text'>XPath 
is a handy expression language for running queries on XML. This post is
about how to use it with XML namespaces in Java (javax.xml.xpath).



This Java code and uses an XPath expression to extract the value
of the bar attribute from a simple document:


  
         XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
    
        String xml = "&lt;data&gt;</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/5033991739319064092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/java-using-xpath-with-namespaces-and.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5033991739319064092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5033991739319064092'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/java-using-xpath-with-namespaces-and.html' title='Java: using XPath with namespaces and implementing NamespaceContext'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2684318626586216311</id><published>2009-05-27T18:17:00.008+01:00</published><updated>2010-01-28T15:02:39.586Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><title type='text'>JSF: using component IDs in a data table (h:dataTable vs clientId)</title><summary type='text'>Updated 2009/11/24

This post is obsolete; go read this one instead:
JSF:
working with component identifiers The approach described in this post
may fail if the component identifiers are not unique within the view.





I've written about how to use a custom function to get the clientId
before.
You can download the code from here.

Below is an example that uses the id:cachedClientId
function in a</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2684318626586216311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/jsf-using-component-ids-in-data-table.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2684318626586216311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2684318626586216311'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/jsf-using-component-ids-in-data-table.html' title='JSF: using component IDs in a data table (h:dataTable vs clientId)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_WbSoVuNp3wY/Sh15JzG5nvI/AAAAAAAAAA0/iM9ZuXY4woE/s72-c/screenyshot.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-6822370680705416123</id><published>2009-05-26T16:38:00.003+01:00</published><updated>2010-01-28T15:03:04.033Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='JRuby'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Jython'/><category scheme='http://www.blogger.com/atom/ns#' term='Groovy'/><title type='text'>Java: dynamically loading scripting engines (Groovy, JRuby and Jython)</title><summary type='text'>Java 6 (via JSR
223) added scripting language support to the standard
library. The JVM ships with the Mozilla
Rhino JavaScript engine included. Where an engine is available, it is
easy to add support for other JVM scripting languages. It is useful to
be able to load these engines dynamically.



This Java 6 code uses the URLClassLoader
class to load and invoke a selection of engines at runtime:

</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/6822370680705416123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/java-dynamically-loading-scripting.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/6822370680705416123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/6822370680705416123'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/java-dynamically-loading-scripting.html' title='Java: dynamically loading scripting engines (Groovy, JRuby and Jython)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-842144623969267015</id><published>2009-05-19T12:28:00.005+01:00</published><updated>2010-01-28T15:03:22.874Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><title type='text'>JSF: IDs and clientIds in Facelets</title><summary type='text'>Updated 2009/11/24

This post is obsolete; go read this one instead:
JSF:
working with component identifiers The approach described in this post
may fail if the component identifiers are not unique within the view.





Facelets is an
alternative view technology to traditional JavaServer Pages and was
designed with JavaServer Faces (JSF) in mind.

I've written before about how IDs work in JSF and</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/842144623969267015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/jsf-ids-and-clientids-in-facelets.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/842144623969267015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/842144623969267015'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/jsf-ids-and-clientids-in-facelets.html' title='JSF: IDs and clientIds in Facelets'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-7544478769225725911</id><published>2009-05-01T19:51:00.011+01:00</published><updated>2010-01-28T15:03:41.364Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>Java: a rough guide to character encoding</title><summary type='text'>It can be tricky figuring out the difference between character
handling code that works and code that just appears to work
because testing did not encounter cases that exposed bugs. This is a
post about some of the pitfalls of character handling in Java.



Topics:


  Unicode in source
  files
  Unicode and Java
  data types
  How long is a (piece of)
  String?
  Encodings
  Stream encoding
  </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/7544478769225725911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/java-rough-guide-to-character-encoding.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7544478769225725911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7544478769225725911'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/05/java-rough-guide-to-character-encoding.html' title='Java: a rough guide to character encoding'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-8500768876752614676</id><published>2009-04-10T13:34:00.002+01:00</published><updated>2010-01-28T15:04:17.342Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>Java: Unicode on the Windows command line</title><summary type='text'>By default, Java encodes Strings sent to System.out
in the default code page. On Windows XP, this means a lossy conversion
to an "ANSI" code page. This is unfortunate, because the Windows Command
Prompt (cmd.exe) can read and write Unicode characters. This post describes
how to use JNA to work round
this problem.

This post is a follow-up to I18N:
Unicode at the Windows command prompt (C++; .Net;</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/8500768876752614676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/04/java-unicode-on-windows-command-line.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8500768876752614676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8500768876752614676'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/04/java-unicode-on-windows-command-line.html' title='Java: Unicode on the Windows command line'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2710474475182445597</id><published>2009-04-09T20:37:00.014+01:00</published><updated>2010-01-28T15:04:40.195Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>I18N: Unicode at the Windows command prompt (C++; .Net; Java)</title><summary type='text'>Strange things can happen when working with characters. It is
important to understand why problems occur and what can be done about
them. This post is about getting Unicode to work at the Windows command
prompt (cmd.exe).



Topics:


  "Penny wise and pound foolish"
  - a character corruption example
  Character encodings and
  code pages
  Switching the Windows console to
  Windows-1252
  </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2710474475182445597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2710474475182445597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2710474475182445597'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html' title='I18N: Unicode at the Windows command prompt (C++; .Net; Java)'/><author><name>McDowell</name><uri>http://www.blogger.com/profile/15240682237791734569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_WbSoVuNp3wY/Sd5PpeIK7EI/AAAAAAAAAAk/RP_dbnXXpPE/s72-c/ya.png' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2743807212773414816</id><published>2009-03-11T10:28:00.001Z</published><updated>2010-01-28T15:04:59.024Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JPDA'/><title type='text'>Java: using JPDA to write a debugger</title><summary type='text'>The Java
Platform Debugger Architecture (JPDA) API included in the JDK lets you
connect to a Java debug session and receive debug events. This code
allows you to do the same things you would normally do with jdb
or an IDE debugger. This is useful if you want to write your own debug,
diagnostics or metrics tools.



Here is some sample code that will be debugged:


 
  &lt;!-- start source code --&gt;
</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2743807212773414816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/03/java-using-jpda-to-write-debugger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2743807212773414816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2743807212773414816'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/03/java-using-jpda-to-write-debugger.html' title='Java: using JPDA to write a debugger'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-5662409484428198414</id><published>2009-02-21T13:37:00.004Z</published><updated>2010-01-28T15:05:43.513Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Java: finding the validation mechanism for an arbitrary XML document</title><summary type='text'>Unfortunately, there is no 100% foolproof process for determining
how to validate an arbitrary XML document. If you are receiving a
document, you should not leave choosing the validation mechanism to a
remote party (e.g. downloading a DTD using its document-specified URI).
Doing so opens your application to, at the very least, a potential
denial-of-service attack. A validation mechanism may not </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/5662409484428198414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/02/java-finding-validation-mechanism-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5662409484428198414'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/5662409484428198414'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/02/java-finding-validation-mechanism-for.html' title='Java: finding the validation mechanism for an arbitrary XML document'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-7569312142919237713</id><published>2009-02-16T13:26:00.015Z</published><updated>2010-01-28T15:06:10.228Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='JSF'/><title type='text'>JSF: working with component IDs (id vs clientId)</title><summary type='text'>Updated 2009/10/17

WARNING: this post is obsolete; go
read this one instead.





JavaServer
Faces components generate their own HTML element id
attributes. How to work with these generated IDs is a source of much
confusion among JSF neophytes. This post aims to explain what is going
on and provides sample code that should make working with IDs a little
bit easier.

Example JSF control in a JSP:</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/7569312142919237713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/02/jsf-working-with-component-ids.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7569312142919237713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7569312142919237713'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/02/jsf-working-with-component-ids.html' title='JSF: working with component IDs (id vs clientId)'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_WbSoVuNp3wY/Strwe2To8yI/AAAAAAAAADQ/3BvKOmvG_Wk/s72-c/button2.png' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2892503911232652776</id><published>2009-02-03T17:45:00.018Z</published><updated>2010-01-28T18:16:03.962Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='i18n'/><title type='text'>I18N: a non-technical software bug</title><summary type='text'>Can you spot the problem with the following dialog?





I expect the developers of the Steam installer are making trade-offs for the benefit of younger users - providing visuals to help match them with their language. 
However, using flags in software products is generally a bad idea.



These flags belong to a few (not even the majority) of the sovereign states that use English as an official </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2892503911232652776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/02/i18n-non-technical-software-bug.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2892503911232652776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2892503911232652776'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2009/02/i18n-non-technical-software-bug.html' title='I18N: a non-technical software bug'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_ycxLxLdAH90/SYiDSZSF8rI/AAAAAAAAAAo/iricJRumxlM/s72-c/flagbug2009.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-2020013805938328054</id><published>2008-12-24T16:38:00.003Z</published><updated>2010-01-28T15:06:32.249Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='bytecode'/><title type='text'>Java: automating the equals method</title><summary type='text'>I spend quite a lot of time writing Java code.
I got to thinking about the time I spent implementing, testing, maintaining and just paging over
equals
/hashCode  implementations.
These common building blocks tend to work much the same way in most classes
and I wondered if there were a way to make them go away.





Implementing equals, hashCode and toString

The DataStructure class below shows a </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/2020013805938328054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/12/java-automating-object-equality.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2020013805938328054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/2020013805938328054'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/12/java-automating-object-equality.html' title='Java: automating the equals method'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-8071737886328033268</id><published>2008-10-02T12:14:00.019+01:00</published><updated>2010-01-28T15:07:28.050Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='streams'/><category scheme='http://www.blogger.com/atom/ns#' term='exceptions'/><title type='text'>Java: how not to make a mess of stream handling</title><summary type='text'>This article was written with Java 6 in mind.

Updated 2008/12/16.


   
  &lt;!-- start source code --&gt;
   
    
  /**
   * Writes "Hello, World!" to a file.
   */
  public static void main(String[] args) {
    try {
      byte[] data = "Hello, World!".getBytes("UTF-8");
      OutputStream out = new FileOutputStream("output.txt");
      //if write throws an error
      out.write(data);
      //then</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/8071737886328033268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/10/java-how-not-to-make-mess-of-stream.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8071737886328033268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8071737886328033268'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/10/java-how-not-to-make-mess-of-stream.html' title='Java: how not to make a mess of stream handling'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3543148797118370216</id><published>2008-08-18T18:37:00.009+01:00</published><updated>2010-01-28T15:07:45.068Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='websphere'/><category scheme='http://www.blogger.com/atom/ns#' term='ant'/><title type='text'>Ant: automated deployment to WebSphere Application Server</title><summary type='text'>It can be useful to automate deployment of enterprise applications to servers during development, either to automatically set up test builds or perform build verification during the kitting process. WebSphere Application Server (WAS) comes with a number of Ant tasks that can be used for this.



Ant in WAS

WAS comes with its own version of Ant. It should be run using the ws_ant.sh script (</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3543148797118370216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/ant-automated-deployment-to-websphere.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3543148797118370216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3543148797118370216'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/ant-automated-deployment-to-websphere.html' title='Ant: automated deployment to WebSphere Application Server'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3897937083744382242</id><published>2008-08-16T14:56:00.012+01:00</published><updated>2011-10-27T21:16:01.202+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rational application developer'/><category scheme='http://www.blogger.com/atom/ns#' term='eclipse'/><category scheme='http://www.blogger.com/atom/ns#' term='subversion'/><title type='text'>HOWTO: Subversion in RAD7 on Fedora 8</title><summary type='text'>A quick HOWTO on setting up Rational Application Developer 7 as a Subversion client on Fedora 8.



Subversion


[user@fedora8 ~]$ yum list | grep subversion
subversion.i386                          1.4.4-7                installed       
subversion-javahl.i386                   1.4.4-7                installed   


Subversion is probably pre-installed; the JNI bindings for the Subversion </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3897937083744382242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/subversion-in-rad7-on-fedora-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3897937083744382242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3897937083744382242'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/subversion-in-rad7-on-fedora-8.html' title='HOWTO: Subversion in RAD7 on Fedora 8'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_ycxLxLdAH90/SKbdSTlMitI/AAAAAAAAAAQ/GIf-jR5Q-Mc/s72-c/Screenshot-Updates.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-9069069835933417999</id><published>2008-08-05T15:41:00.007+01:00</published><updated>2010-01-28T15:08:18.054Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='basics'/><title type='text'>Java: int versus Integer</title><summary type='text'>Changes in the Java language have blurred the functions of int
and java.lang.Integer. However, every Java developer should
understand the distinction between the two.



Confusion arises because the two sets of code in the method below
seem to be the same:


  
       /* Java 5 syntax */
      public static void main(String[] args) {
        // adding ints
        int a = 1;
        int b = 1;
</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/9069069835933417999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/java-int-versus-integer.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/9069069835933417999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/9069069835933417999'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/java-int-versus-integer.html' title='Java: int versus Integer'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_WbSoVuNp3wY/SyJDELCMTKI/AAAAAAAAAD4/Z4qjQuQZOaM/s72-c/integer.png' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4171282393860898441</id><published>2008-08-01T15:20:00.004+01:00</published><updated>2010-01-29T15:23:44.633Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='XMLBeans'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Java: using XMLBeans to edit web.xml</title><summary type='text'>XMLBeans is a Java API and set of utilities for working with XML. The code that follows demonstrates how to use it to manipulate a J2EE web.xml (version 2.5) document.





Generating Java Beans from a Schema

The XMLBeans scomp tool (schema compiler) is used to generate beans from a schema. It requires a Java compiler to do this. Here is the tool in action:


C:&gt;%XMLBEANS_HOME%\bin\scomp -src .\</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4171282393860898441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/java-using-xmlbeans-to-edit-webxml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4171282393860898441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4171282393860898441'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/08/java-using-xmlbeans-to-edit-webxml.html' title='Java: using XMLBeans to edit web.xml'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4852150685641287049</id><published>2008-07-31T00:52:00.002+01:00</published><updated>2010-01-29T15:24:18.182Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>Java: determining the version of an XML document</title><summary type='text'>When working with XML in Java, it is not uncommon to want to work with the data using strongly typed objects that enforce the document structure. That is, you want to use Java Beans rather than a Document Object Model (DOM).



A number of technologies can be used to automate this transformation, such as
the Apache Commons Digester (a rules-based entity mapper) or XMLBeans (which provides </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4852150685641287049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/07/java-determining-version-of-xml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4852150685641287049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4852150685641287049'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/07/java-determining-version-of-xml.html' title='Java: determining the version of an XML document'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-7980709260331482235</id><published>2008-06-30T13:36:00.001+01:00</published><updated>2010-01-29T15:24:42.850Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java: class names</title><summary type='text'>
In Java, it is possible to get a String representation of a class by calling the Class.getName() method.
Since Java 1.5 (AKA Java 5), it has been possible to get the canonical name using Class.getCanonicalName().
 




javadoc: java.lang.Class


For many classes, these two methods will return identical values. Things get more interesting when it comes to some of the more esoteric types such as </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/7980709260331482235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/06/java-class-names.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7980709260331482235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7980709260331482235'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/06/java-class-names.html' title='Java: class names'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3318230972465625047</id><published>2008-05-26T00:01:00.002+01:00</published><updated>2010-01-29T15:24:58.720Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='hexadecimal'/><title type='text'>C: hex dump application</title><summary type='text'>A C version of PrintHex to avoid a dependency on Mono.





Compilation, usage and output:



$ gcc phex.c -o phex
$ ./phex phex.h
23 69 6E 63 6C 75 64 65 20 3C 73 74 64 69 6F 2E         #include &lt;stdio.
68 3E 0D 0A 0D 0A 76 6F 69 64 20 70 72 69 6E 74         h&gt;____void print
46 69 6C 65 41 73 48 65 78 28 46 49 4C 45 2A 20         FileAsHex(FILE*
66 69 6C 65 29 3B 0D 0A 63 68 61 72 20 74 6F 56</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3318230972465625047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/c-hex-dump-application.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3318230972465625047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3318230972465625047'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/c-hex-dump-application.html' title='C: hex dump application'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4163762977631083501</id><published>2008-05-25T14:26:00.001+01:00</published><updated>2008-05-25T14:42:50.536+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Hello World'/><title type='text'>C: Hello, World!</title><summary type='text'>gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)



#include &lt;stdio.h&gt;

int main() {
    printf("Hello, World!\n");
    return 0;
}

</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4163762977631083501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/c-hello-world.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4163762977631083501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4163762977631083501'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/c-hello-world.html' title='C: Hello, World!'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-8866620450454356184</id><published>2008-05-01T22:59:00.001+01:00</published><updated>2010-01-29T15:25:43.769Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='DOS'/><category scheme='http://www.blogger.com/atom/ns#' term='assembler'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Hello World'/><title type='text'>Java: generating a DOS executable</title><summary type='text'>By incrementally changing instructions in an assembly language, it is possible to build up a picture of how the bytes relate to the assembly instructions (without going to the trouble of actually reading the documentation). Note that, for these trivial examples at least, there is no difference between the binaries generated by NASM and the equivalent MS Debug instructions.





NASM version </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/8866620450454356184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/binary-generating-dos-executable-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8866620450454356184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8866620450454356184'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/binary-generating-dos-executable-in.html' title='Java: generating a DOS executable'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3261832309091425941</id><published>2008-05-01T18:29:00.000+01:00</published><updated>2008-05-01T19:57:41.522+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DOS'/><category scheme='http://www.blogger.com/atom/ns#' term='assembler'/><category scheme='http://www.blogger.com/atom/ns#' term='NASM'/><category scheme='http://www.blogger.com/atom/ns#' term='Hello World'/><title type='text'>Assembler: Hello, World! [2]</title><summary type='text'>NASM version 0.98.39 compiled on Feb 25 2005
DOS, 16bit, x86


;syntax expected by NASM
;DOS, x86, 16bit
org 100h        ;start at address 100
mov ax,0200h    ;AH=2
mov dx,0048h    ;'H'
int 21h         ;int 21,2 (print char)
mov dx,0065h    ;'e'
int 21h
mov dx,006Ch    ;'l'
int 21h
mov dx,006Ch    ;'l'
int 21h
mov dx,006Fh    ;'o'
int 21h
mov dx,002Ch    ;','
int 21h
mov dx,0020h    ;' '
int 21h
</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3261832309091425941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/assembler-hello-world-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3261832309091425941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3261832309091425941'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/assembler-hello-world-2.html' title='Assembler: Hello, World! [2]'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-7670514896844675927</id><published>2008-05-01T09:29:00.001+01:00</published><updated>2010-01-29T15:29:26.846Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='DOS'/><category scheme='http://www.blogger.com/atom/ns#' term='assembler'/><category scheme='http://www.blogger.com/atom/ns#' term='x86'/><category scheme='http://www.blogger.com/atom/ns#' term='debug.exe'/><title type='text'>Assembler: using debug.exe to write DOS programs</title><summary type='text'>C:\WINDOWS\system32\debug.exe



Windows (XP) still comes with Debug.




C:\test&gt;DEBUG
-a
0C8A:0100 mov ax,0200
0C8A:0103 mov dx,0041
0C8A:0106 int 21
0C8A:0108 int 20
0C8A:010A
-h 010A 0100
020A  000A
-n PCHAR.COM
-rcx
CX 0000
:000A
-w
Writing 0000A bytes
-q

C:\test&gt;PCHAR.COM
A






The above is the console output for writing a 10 byte executable in assembly language. All the application does</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/7670514896844675927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/assembler-using-debugexe-to-write-dos.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7670514896844675927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7670514896844675927'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/05/assembler-using-debugexe-to-write-dos.html' title='Assembler: using debug.exe to write DOS programs'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-1226215086258835192</id><published>2008-05-01T00:25:00.001+01:00</published><updated>2008-05-01T18:29:16.995+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DOS'/><category scheme='http://www.blogger.com/atom/ns#' term='assembler'/><category scheme='http://www.blogger.com/atom/ns#' term='x86'/><category scheme='http://www.blogger.com/atom/ns#' term='debug.exe'/><category scheme='http://www.blogger.com/atom/ns#' term='Hello World'/><title type='text'>Assembler: Hello, World!</title><summary type='text'>DOS, x86, 16bit, debug.exe


mov ax,0200
mov dx,0048
int 21
mov dx,0065
int 21
mov dx,006C
int 21
mov dx,006C
int 21
mov dx,006F
int 21
mov dx,002C
int 21
mov dx,0020
int 21
mov dx,0057
int 21
mov dx,006F
int 21
mov dx,0072
int 21
mov dx,006C
int 21
mov dx,0064
int 21
mov dx,0021
int 21
int 20
</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/1226215086258835192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/assembler-hello-world.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1226215086258835192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1226215086258835192'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/assembler-hello-world.html' title='Assembler: Hello, World!'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-7669051460906114778</id><published>2008-04-30T21:37:00.001+01:00</published><updated>2010-01-29T15:28:21.049Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='hexadecimal'/><title type='text'>C#: file hex dump application</title><summary type='text'>A simple application for printing file contents as hexadecimal.





Usage

For multiple bytes per line:



C:\&gt;   PrintHex.exe -h PrintHex.cs



Sample output:


75 73 69 6E 67 20 53 79 73 74 65 6D 3B 0D 0A 75   using System;__u
73 69 6E 67 20 53 79 73 74 65 6D 2E 49 4F 3B 0D   sing System.IO;_
0A 0D 0A 2F 2A 2A 0D 0A 2A 20 41 70 70 6C 69 63   ___/**__* Applic
61 74 69 6F 6E 20 66 6F 72 20 70 72</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/7669051460906114778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/c-file-hex-dump-application.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7669051460906114778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/7669051460906114778'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/c-file-hex-dump-application.html' title='C#: file hex dump application'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-8807208727150724299</id><published>2008-04-29T11:26:00.000+01:00</published><updated>2008-04-29T11:27:06.615+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Hello World'/><title type='text'>C#: Hello, World!</title><summary type='text'>using System;

public class HelloWorld {
        public static void Main(String[] args) {
                Console.WriteLine("Hello, World!");
        }
}

</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/8807208727150724299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/c-hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8807208727150724299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/8807208727150724299'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/c-hello-world.html' title='C#: Hello, World!'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-3008868020979828866</id><published>2008-04-22T13:05:00.002+01:00</published><updated>2010-01-29T15:26:29.274Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='JUEL'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='EL'/><category scheme='http://www.blogger.com/atom/ns#' term='Unified Expression Language'/><category scheme='http://www.blogger.com/atom/ns#' term='Tomcat'/><category scheme='http://www.blogger.com/atom/ns#' term='Expression Language'/><title type='text'>Java: using EL outside J2EE</title><summary type='text'>


   ${example.expression.language.expression}




If you have done much JSP programming, you will be familiar with the Expression Language (EL), also now known as the Unified Expression Language. EL is used in JSPs to help remove business logic from the view while keeping the data content dynamic. Uses for EL can go beyond J2EE platforms and it is relatively easy to incorporate it into your own</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/3008868020979828866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-using-el-outside-j2ee.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3008868020979828866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/3008868020979828866'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-using-el-outside-j2ee.html' title='Java: using EL outside J2EE'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4841447884615775201</id><published>2008-04-14T00:05:00.001+01:00</published><updated>2010-01-29T15:30:25.590Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='BCEL'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='dependencies'/><category scheme='http://www.blogger.com/atom/ns#' term='byte code engineering library'/><title type='text'>Java: finding binary class dependencies with BCEL</title><summary type='text'>Sometimes you need to find all the dependencies for a binary class. You might have a project that depends on a large product and want to figure out the minimum set of libraries to copy to create a build environment. You might want to check for missing dependencies during the kitting process.






   
  &lt;!-- start source code --&gt;
   
    
package foo;

public class Bar implements Runnable {

  </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4841447884615775201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-finding-binary-class-dependencies.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4841447884615775201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4841447884615775201'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-finding-binary-class-dependencies.html' title='Java: finding binary class dependencies with BCEL'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4978309932996112018</id><published>2008-04-09T12:30:00.002+01:00</published><updated>2010-01-29T15:27:44.420Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java: finding the application directory</title><summary type='text'>EDIT 2009/05/28: It has been pointed out to me that a far easier way to do all this is using this method:


   
   
    
    URL url = Location.class.getProtectionDomain()
        .getCodeSource().getLocation();
   
   


...which makes everything below here pointless. You live and learn!





If you are writing a rich client application, you may want to find the place where the system owner has </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4978309932996112018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-finding-application-directory.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4978309932996112018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4978309932996112018'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-finding-application-directory.html' title='Java: finding the application directory'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-1364358490428938721</id><published>2008-04-08T18:37:00.007+01:00</published><updated>2010-01-29T15:27:17.021Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='synchronization'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='mutex'/><category scheme='http://www.blogger.com/atom/ns#' term='concurrency'/><title type='text'>Java: synchronizing on an ID</title><summary type='text'>If you are a Java programmer, you will be familiar with synchronized blocks.


  Object myObject = //some instance
  synchronized(myObject) {
   //do some thread-sensitive
   //work on myObject
  }


Sometimes, you want to synchronize on a transient object - a resource that isn't going to stay in memory.



For example, there is nothing in the Servlet 2.5 MR6 specification that says a </summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/1364358490428938721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-synchronizing-on-transient-id.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1364358490428938721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/1364358490428938721'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/java-synchronizing-on-transient-id.html' title='Java: synchronizing on an ID'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2083400580050165811.post-4929248167738303248</id><published>2008-04-08T10:44:00.000+01:00</published><updated>2008-04-29T11:28:21.690+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Hello World'/><title type='text'>Java: Hello, World!</title><summary type='text'>
   
  &lt;!-- start source code --&gt;
   
    
public class HelloWorld {
   public static void main(String[] args) {
       System.out.println("Hello, World!");
   }
}
    
   
  &lt;!-- end source code --&gt;
   
</summary><link rel='replies' type='application/atom+xml' href='http://illegalargumentexception.blogspot.com/feeds/4929248167738303248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/hello-world.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4929248167738303248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2083400580050165811/posts/default/4929248167738303248'/><link rel='alternate' type='text/html' href='http://illegalargumentexception.blogspot.com/2008/04/hello-world.html' title='Java: Hello, World!'/><author><name>McDowell</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
