Java Equals and HashCode by Reflection

Writing proper ”equals()” and ”hashCode()” methods A class which is to be used in Maps and Sets must always have their equals() and hashCode() method overridden so that they reflect the data structure of the actual object. This means that the fields of the object which are required for equality must be taken into account […]

Debugging And Logging Java RMI Calls

If you ever need to debug Java RMI, then add these properties to the VM configuration: -Djava.rmi.server.logCalls=true -Dsun.rmi.server.logLevel=VERBOSE -Dsun.rmi.client.logCalls=true -Dsun.rmi.transport.tcp.logLevel=VERBOSE

Implementing Ajax push with RichFaces

The following snippets illustrates how to implement an ajax push in a JSF application where RichFaces is set up. I am using this with a JSF application with Tomahawk extensions and RichFaces just for Ajax and Menus Add the following in the XHTML: <!– Register an ajax listener on the bean –> <a4j:push interval=”1000″ eventProducer=”#{bean.addPushListener}” […]

Creating icons for eclipse applications

I’ve been starting to get quite annoyed with problems surrounding creating icons for use in eclipse applications. Windows needs either alot of icons in 8bit and 32bit or one ico containing all of those images. Anyhow after some trying I found out how I could get this done. First you create your icon in a […]

Running Task asynchronously in Eclipse RCP and JFace

These code snippets show how it is possible to executes task in Eclipse by showing a progress dialog, which is possible to hide This is the code to start the job: // create action to be called after the action is completed // this action shows a success dialog if the job executed without // […]

JAVA and JAR’s from the command line

This is a small little tutorial which will explain how to create your own little Java application which have dependencies which are in other JAR files First create the following directory structure: java_test | |__myapp | |__src | | |__ch | | |__eitchnet | | |__java | | |__Main.java | |__META-INF | | |__MANIFEST.MF | […]

JSF and PDF’s

This is a quick snipped on transmitting a PDF in a JSF context: byte[] bytes = getPDFStreamAsArray(); FacesContext faces = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) faces.getExternalContext() .getResponse(); response.reset(); response.setContentType(“application/pdf”); response.setContentLength(bytes.length); response.setHeader(“Content-disposition”, “inline;filename=”file.pdf””); // inline or attachment response.setHeader(“Cache-Control”, “cache, must-revalidate”); ServletOutputStream out = response.getOutputStream(); out.write(bytes); faces.responseComplete();

JSF and EL (Expression Language) rant !

Beware people… Referring to missing methods in a Bean from a XHTML page using the expression language yields an exception, but referring to a *private* method, doesn’t to nothing. No exception, no message, just plain and simply nothing. I spent hours trying to understand why my application didn’t work, and now I know it: Be […]

Java RMI quick and dirty

Your object which will be accessible through RMI must meet the following requirements: have its own interfaces which extends java.rmi.Remote all methods must “throws RemoteException“ all returned returned objects must implement java.io.Serializable Starting a RMI server: Set system property: System.setProperty(“java.rmi.server.hostname”, “hostname”); create registry: Registry registry = LocateRegistry.createRegistry(1099); export Object: RemotableObject stub = (RemotableObject) UnicastRemoteObject.exportObject(remoteObject, 0); […]

Apache Tomcat 6.0 configuration for developers

Just a quick blog on configuring some specific Tomcat 6.0 settings: Memory Heap Size on a unix based system Open the file %tomcat_install_folder%/bin/startup.sh Add the line: export CATALINA_OPTS=”-Xms256m -Xmx512m” before the line: exec “$PRGDIR”/”$EXECUTABLE” start “$@” to have a memory heap of at least 256mb and max of 512mb. Memory Heap Size on a Windows […]