Posts

Showing posts from 2008

JavaDoc tool doesn't export the Method's Javadocs

My boss wanted me to deliver a full list of all of my JUnit tests I did on my code. When he saw my exasperated expression he offered me to just export the test's javadocs and deliver it as a report, well that made me happy :-) I've adopted writing javadocs all of the time as a good coding practice, so this task shouldn't have made me any problems, but... it did. As you well know, I use Eclipse as my IDE, so I just went to file --> export --> javadoc. Cool, everything seemed to work like a charm, till I looked at the javadocs - all was documented nicely except for - the method's javadocs, and that is where most of my javadocs are written. What was my problem? I found out that because I use JUnit 4 as my unit testing engine, I must use a @Test annotation, then I write my javadoc, here's my bug, apparently, when the tool sees an annotation it assumes the method's declaration has started, so when it tries exporting javadocs it doesn't look after any annota

Basic ANT build file Template

It happens all of the time, I want to write a new ANT build file, I don't really remember how to begin, so, I just copy a working build file and then I start removing most of its content. Well, that's not so productive and is a bad practice in general, so for the benefit of all (me included), I've decided doing the same process for the last time, in order to create a basic Ant template file from which I will be able to begin each time. This template contains only the most basic Ant build file. Basic example which shows how to: Create a basic Ant build file. Usage of a property. Usage of a Target (Method / Procedure). Dependency of targets. <?xml version="1.0" encoding="ISO-8859-1"?> <project name="BasicTemplate" default="all"> <property name="distribution" value="${basedir}/dist" /> <target name="init" description="Some initialization acts which should run at the begining"&g

SVN Externals spaces handling

There is some sort of SVN error which doesn't allow one to use spaces in ones directory structure when using the "externals" svn property. The solution to this one is quite short and simple: Instead of using spaces, use %20  which the svn does understand as a space character. So if your external consists of something like this: "my project/dist" rewrite it to: "my%20project/dist". Yeah, i know, ugly... but it works. BTW - Maybe this isn't a general SVN problem, it might just be a TortoiseSVN problem.

Help me become a great Java developer - What should I learn?

This is the subject of an email I got today, the rest of the email is as follows: Hi Chaiavi, Whats up? I didn't work on java for a while now, i am trying to become the best Java developer ever - well not ever there will always be you ;-) so that in the future job interviews i will actually know something :-) and i need your help to guide me in the right direction :- where to start? what are more/less impotent subjects? what are the best places to learn from, so that I will learn a lot in short time with as little effort as possible that it will be easy fun and not boring and that I can finish before the next job interview (whenever it will be) i am looking for online sites, video eLearning and even books if they are really good (since books takes a lot of time to learn from) you know what, ignore everything i just said and just guide me into becoming the great Java developer i can be. Thanks, John Doe. -------------------------------------------------------------------------------

Bad Unmarshalling of a CXF object which results in a null object

The story in short: I have a webservice which gathers some information from my DB, creates an object containing the info, then sends it to my client. Sounds like a simple CXF webservice scene? Well, for the last two days i'm fighting it; why? Cause my client gets only a nullified object, it's quite frustrating... So i caused some logs to appear and discovered that - The SOAP message actually contains the whole Object. My client just can't build it (Unmarshal it) into the object it's supposed to be. So, whose fault is it and how do I fix it? Aegis' binding is my guess (not that it helps much), so that's the road i'm taking. What did I find (OK, what did my boss find?) ? Here are some interesting things that I learned in the process of getting the Peering WS client to connect up with the Peering WS: The basic mechanism for serializing and deserializing the data of a web service is the databinding implementation.  I’ve been using Aegis, which is described

JUnit 4 Template Class

Each time I want to create a JUnit test class, I take a look at an older one, copy it, then remove all of the specifics of the previous tests. That isn't a good practice  :-) So I've decided to do it once more, in order to create a template - a working JUnit class which doesn't do anything, just add your specific code you want to test and run along: package org.chaiavi.TestJunit; import java.io.IOException; import org.junit.*; import static org.junit.Assert.*; public class TestJunit{ /** Use this method for all of the lines of code you want to run before the whole JUnit Class. */ @BeforeClass     public static void unitSetup() throws Exception { } /** Use this method for all of the lines of code you want to run after the whole JUnit Class. */ @AfterClass     public static void unitCleanup() throws Exception {     }  /** Use this method for all of the lines of code you want to run before each JUnit test. */ @Before     public void methodSetup() throws Exception

Master of Magic - Game Remake

Do you remember this game? I used to play it for days over days - really loved it. So, for the sake of nostalgy I decided to search for the game in order to play it, to no avail, the game works only on a dos machine. So i've tried playing it using a good DOS emulator: DosBox, but it didn't go well. I searched harder and found a new version of Master of Magic which works on XP. So, if you are suckers to nostalgy, And if you have some spare time, Give it a try. The game can be downloaded from here: First part  , Second Part  . The dos game is abandonware thus freeware, The XP version is also freeware from Implode's site. Enjoy, Chaiavi.

How do you know that your Unit tests cover all of your code? use a good Code Coverage tool

Unit Tests and Code Coverage Unit Tests In computer programming, unit testing is a procedure used to validate that individual units of source code are working properly. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method; which may belong to a base/super class, abstract class or derived/child class. Ideally, each test case is independent from the others; mock objects and test harnesses can be used to assist testing a module in isolation. Unit testing is typically done by developers and not by end-users. (Taken from WikiPedia) Code Coverage The Unit tests are a good measure of testing, but how much of the code is being covered? Did the unit test check all of the paths of the code flow? These are the issues the Code coverage helps us solve. The Code Coverage Tools run the Unit Tests we created and tell us explicitly how much cod

Did you try parsing a number residing in a String and an exception occured when that number was 8 or 9?

Parsing String numbers When parsing numbers residing in Strings one should pay attention to the parsing method. There are several parsing methods in the Integer Class, and not all of them parse the numbers in a Decimal (Base 10) order. For example if you'll try running the following line of code - an exception will be thrown: Integer i = Integer.decode("09"); The exception will be thrown due to the simple fact that there is no numeric character 09 when you use an Octalic counting base (Which is the decode method's default). Try using a different method for a Decimal based number. So, in order to correct our specific example we should use: Integer i = Integer.parseInt("09");

Do you wish you could debug with your local Eclipse a Java program running on an other machine ... remotely?

Remote Debugging The General debug flow. In order to debug with your Eclipse a Java program that runs on an other machine, you will need to configure two components, one in the remote machine (Where the Java program runs) and the second is a local configuration addition to your Eclipse IDE. The Remote machine will run the Java program using a special command line argument which will tell the JVM that an external debugger will connect to it and how it will connect to it (Connection type, Port etc). The Local Machine which runs Eclipse should use a special debugging mode, configured to connect to the remote Java program. The Explicit configurations. Configuring the Remote Java program. When running the program just add these command line arguments after the "java" command before the "-jar" argument (For more detailed information about these arguments - read the article which it's link is attached below): -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,suspend=n

Do you want your Log4J to send you emails with notifications?

Log4j.SMTPAppender Include the following files in the Component’s Classpath:   mail.jar   and   activation.jar . This appender’s trigger for sending an alert email is ERROR or FATAL. Lesser logs cannot be a trigger to send an email although they can be cached to be sent later on (bundled with a trigger level) when an ERROR / FATAL log occurs. In order to enable lesser than ERROR level logs, two arguments should be defined:   BufferSize   and   threshold . For an   XML   file use the following lines: <appender name="mail" class="org.apache.log4j.net.SMTPAppender"> <param name="SMTPHost" value="172.16.100.3" /> <param name="From" value="ChaiAvi@Chaiware.googlepages.com" /> <param name="To" value="Chaiavi@Chaiware.googlepages.com" /> <param name="Subject" value="[LOG] ..." /> <param name="BufferSize" value="2" /> <param name=&

Does your Application stall for several seconds (or more)?

Garbage Collection If you have a Java app that handles large volumes of data but your app hangs randomly for several seconds (or even minutes), a good call will be a wrong configuration of Java's Garbage Collection. What can be done? First of all lets get some of the garbage collector's  logs . In order to see the GC's logging (Stdout) details, use these command line parameters: -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps Eg: java -jar -verbose:gc -XX:+PrintGCTimeStamps java_app.jar Now to the actual garbage collecting. Apparently Java 1.5 has three different  fixed garbage collection modes . The fixed garbage collection modes are: -XX:+UseConcMarkSweepGC -XX:+UseParallelGC -XX:ParallelGCThreads= -XX:+UseTrainGC Eg: java -jar -verbose:gc -XX:+PrintGCTimeStamps -XX:+UseParallelGC java_app.jar If you find the fixed garbage collection modes not satisfying enough, you can configure the garbage collector manually with several additional command line parameters, use th

WARNING: Can't find the the request for http://127.0.0.1:8080/... 's Observer

When did this stackTrace been thrown? While running a CXF webservice over a tomcat server. Scenario: My client (client software) tries to connect the CXF webservice, but the following line keeps being stacked at my server's console windows: WARNING: Can't find the the request for http://127.0.0.1:8080/... 's Observer What's the problem? After thorough investigation I tried invoking a services list using my web browser - And a list I got! Where I found out that I wrote the wrong endpoint Mystery solved :-)

Olympus Voice Recorder

My friend gave me his Olympus Voice Recorder VN-120PC. He needed some piece of software with which he could copy the files from the recorder to his computer. Well, after some searching, I saw it wasn't such an easy task, that's the reason for the post. If you are an owner of such a recorder (or one of its siblings which can use the same software) - you won't need to search any further. Olympus's Digital Wave Player is at your service to copy the files using a USB cable - to your PC. I have two versions, The first for win2000 and winxp, while the second is for win98. Driver for Windows2000 & Windows XP Driver for Windows 98 These drivers and software match also the DW90 recroder. Enjoy.

ZVR converter

Yesterday, a friend asked me to find him a ZVR sound file converter. What's the problem? I asked... Give me 5 minutes and i'll google it out. Well, I was wrong, finding a decent converter isn't an easy task, it took me at least 7 minutes (kidding). What's a ZVR file? It's a dictation recorder output file, used by the korean SAFA company, their recording machine is used mainly to capture sound files using its microphone during class lessons or whenever one wants. I just don't get it, why each company comes up with its own sound format?  grab a good and free existing audio format and stick to it! The ZVR files are very small hence their low quality... Anyway, a nice ZVR to WAV file converter was found. It's an incredibly small file (140kb). Download ZVR sound file converter  Enjoy, Avi.