Create Excel CSV files with ease

Now I know that creating a comma separated file is no big deal, and is quite trivial. I am sure that everyone, at one time or another, has written a program where they either had to read and/or write a CSV file. I know that I have had to do this on numerous occasions. I use to add quotations and comma‘s in my data to delineate the different fields. As this does work, I never took the time to create a set of utilities in a jar file that I could import into any of my projects and easy call and use.

Well instead of creating my own code utility I did a little searching on the internet. Low and behold I found the Ostermiller Java Utilities which provides everything that I ever wanted in writing and reading CSV files. Not only does the author provide you with a easy and reusable way of working with CSV file, he has incorporated a bunch of other utilities for you as well. I have found that his Java CSV utilities to be very easy to use and are well documented with nice examples. I like the way that the author has incorporated different calls for created not only regular CSV files but has incorporated all the rules necessary for creating Excel CSV formats. Using this tool, I have never had a issue with another application reading my CSV output.

His tool does not only assist you while working with CSV files, but he has also created many other useful utility that can just simply save you time. Here is a list from his site what the utility provides.

  • ArrayHelper – Helpful utilities for working with arrays.
  • Base64 – Encode and decode base 64.
  • Browser – Open a browser from an application on Windows, Unix, or Macintosh.
  • CGI Query String Parser – Libraries to to parse the query data supplied by HTTP GET or POST requests.
  • Circular Buffers – Implements the circular buffer producer/consumer model for bytes.
  • Command Line Parser – Handle options and arguments to Java command line programs.
  • Concatenation Streams – Combine multiple streams of incoming data to create a single stream.
  • Comma Separated Values (CSV) – Libraries to read and write files in Comma Separated Value (CSV) format. (Excel CSV Format also available)
  • Exec Helper – Convenience methods for executing external applications that output data.
  • File Helper – Methods for manipulating files.
  • Iterators and Enumerations – Convert between Iterators and Enumerations or convert arrays to Iterators or Enumerations.
  • Line Ends – Converts text files between various system formats.
  • MD5 Sums – Classes for generating MD5 checksums on String, Byte arrays, Streams, or Files.
  • NoClose Streams – Create streams that cannot be closed with the regular close() mechanism.
  • Parallelizer – Runs multiple jobs in parallel, n threads at a time, and waits until all threads are complete before continuing.
  • Password Dialog – A password dialog box written for Swing.
  • Random Password Generator – Generate a random String using a cryptographically secure random number generator.
  • Significant Figures – Handles parsing, rounding, and displaying numbers for scientific applications.
  • Size Limit Input Stream – Create a substream of a specified length from an existing input stream.
  • String Helper – Methods for formatting, manipulating, and querying Strings.
  • String Tokenizer – A StringTokenizer replacement with enhancements.
  • Straight Stream Reader – An input stream reader that does no character class translation.
  • Tabs – Tab adjuster that can convert tabs to spaces and vice versa.
  • Uber Properties – A replacement for the java.utils.Properties class with enhancements.

Posted on Aug 13, 2008 by Mike Jennings in Java | 2 Comments | Permalink

Installing Oracle Application Server 10.1.3.1 on Centos 5 server

I am in the process of getting Shibboleth service providers setup on machines in our web environment. The newest, and one of the most urgent service provider that I have to setup is running on a Oracle Application Server. I wanted to get this setup and running in a local test environment so I can show the admins what needs to be done. I decided to get my test system setup under a Virtual Machine in Parallels on my Mac OSX running Centos 5 I had a few hurdles in getting the software installed, but this is what I did.

  1. Downloaded the Centos 5 installation image from here.
  2. Downloaded the Oracle Application Server Deployment Edition from here.
  3. Created a Parallels Virtual machine and ran the Centos 5 DVD iso image to setup to machine. (You will need a gui environment to run the Oracle Universal Installer)
  4. Ftp'd the Oracle Application Server CIPO file to the Centos 5 VM.
  5. Ran this command to expand the cipo file cipo -idv <
  6. Commented out the line under [Certified Versions] in the oraparam.ini file located in the install directory to make it so dependency checking is turned off.
  7. Installed the following files. (I found this in the install instructions here, but I just used yum instead of getting the files from the disk)
    
    # From CentOS 5.1 – [CD #1]
    mkdir -p /media/cdrom
    mount -r /dev/cdrom /media/cdrom
    cd /media/cdrom/CentOS
    rpm –Uvh binutils-2.*
    rpm –Uvh glibc-2*
    rpm –Uvh glibc-common-2.*
    rpm –Uvh libaio-0*
    rpm –Uvh libgcc-4.*
    rpm –Uvh libstdc++-4.*
    rpm –Uvh make-3*
    rpm –Uvh setarch-2*
    cd /
    eject
    
    # From CentOS 5.1 – [CD #2]
    mount -r /dev/cdrom /media/cdrom
    cd /media/cdrom/CentOS
    rpm –Uvh glibc-devel-2.*
    rpm –Uvh gcc-4*
    rpm –Uvh gcc-c++-4.*
    rpm –Uvh libstdc++-devel-4.*
    cd /
    eject
    
    # From CentOS 5.1 – [CD #3]
    mount -r /dev/cdrom /media/cdrom
    cd /media/cdrom/CentOS
    rpm –Uvh compat-db-4*
    rpm –Uvh compat-gcc-34–3*
    rpm –Uvh compat-gcc-34-c++-3*
    rpm –Uvh compat-libstdc++-33–3*
    rpm –Uvh libaio-devel-0.*
    rpm –Uvh libXp-1*
    rpm –Uvh openmotif-2*
    rpm –Uvh sysstat-7.*
    cd /
    eject
    
  8. Next I installed the following rpm becuase I was getting a libdb.so.2 library not found exception. I found the instructions to fix it here.

    1. I did a Google search on "db1-1.85-8.i386" and found man pages that had a link to the rpm I needed.

    2. I downloaded the rpm, within the centos gui, and it asked me to install the rpm.

    3. I installed the rpm, and the library was now available.

  9. Now all I had to do was run the installation of ./runInstallation and everything worked great for me.

I hope that you found this helpful. Please leave comments or extra tips and I will add them to this page.

Posted on Aug 05, 2008 by Mike Jennings in Java | 0 Comments | Permalink

Is there a virtual machine for Windows?

I have recently been in search of a good Virtual Machine so I can setup some development servers on my Windows machine. I first tried VirtualBox to run a few different types of Linux distributions. VirtualBox at first seemed to work ok, and since it was recently purchased by Sun I thought that there was a lot of promise here. What ended up happening is that my laptops processor started getter hotter than HELL and crashed all the time on me. This was frustrating.

Next I tried VMware Server. This Virtual Machine worked a lot better than VirtualBox. Screen resolutions and hardware on my laptop were recognized with ease. The processor ran much cooler, which was a bonus. I hate the configuration of the network devices, which I find kinda cumbersome. Other than that, I find VMware a much better product.

I am just wondering if anyone has a better alternative for me. I guess I am just spoiled because I use Parallels at work on my MacBook Pro. Parallels just works great, but maby that is because it is running on a Mac. I find working in Virtual Machines as a development tool great, but have only come to this realization after having a Mac.

Posted on Jul 21, 2008 by Mike Jennings in Java | 0 Comments | Permalink

Using Spring 2.x to wire Model 1 Servlets

At work I am currently maintaining a older, Model 1 Servlet application. This application is working great in production, even though I think the overall back end design is about as pretty as the Elephant Man! I have always longed for better ways to add functionality to the code, and long for using Spring in parts of the applications.

Well recently I needed to migrate some Spring code from another application into this old one. My first thought is, oh crap, this is going to be interesting. Well things were interesting indeed, and for the positive. I found that there is a nice, clean way to integrate the Spring Framework with my current HTTP Servlets.

First I identified that I would like to have spring wire up some Database Calls in my LoginServlet. To do this I had to make a change to the web.xml to use the ContextLoaderListener class and load the applicaitonContext.xml file.

        <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>
            /WEB-INF/applicationContext.xml
          </param-value>
        </context-param>
        
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
Now that these spring is setup to go, I have identified that the LoginServlet is going to be wired using some spring code. To do this I change my web.xml file to use the HttpRequestHandlerServlet in Spring for the LoginServlet servlet-class definition.
	<servlet>
		<servlet-name>LoginServlet</servlet-name> 
		<display-name>LoginServlet</display-name>
		<!-- servlet-class>edu.unc.ais.bs.onecard.servlets.LoginServlet</servlet-class -->
                <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
	</servlet>
Next I need to reference the LoginServlet class that is in my application and have is wired with Spring. To do this I created a Spring bean in the applicationContext with the same id name as the servlet-name parameter in the web.xml.
   <bean id="LoginServlet" class="edu.unc.ais.bs.onecard.servlets.LoginServlet">
      <property name="hrEmpApptDataDAO" ref="hrEmpApptDataDAO"/>
      <property name="oneCardAccountDAO" ref="oneCardAccountDAO"/>
      <property name="oneCardSvcDAO" ref="oneCardSvcDAO"/>
   </bean>
The last piece is pretty easy, just go to LoginServlet class and implement the HttpRequestHandler as so.
public class LoginServlet implements HttpRequestHandler {
This will require you to add the handleRequest method to the servlet, which is what is called when you access the servlet from your applicaiton. The doGet and doPost, and other default methods are overridden and handled for you by default. That was it. Now I have this old servlet, which I can wire up and pass Spring JdbcTemplete objects to.

Posted on Jun 04, 2008 by Mike Jennings in Java | 0 Comments | Permalink

Battle of the Web Frameworks Podcast

I wrote a article talking about how Manning Publications was hosting a debate called Battle of the Frameworks! A Roundtable Debate.

Now thanks to Ken Rimple of Chariot Solutions you can listen to the debate online by going to the podcasts listed below.

Manning Web Framework Shootout Part 1
Manning Web Framework Shootout Part 2

Ken has done a great job with getting this information out to the community. It is a great discussion and part two gets pretty heated between the Java and Ruby camps.

I would love to here what people think of this debate, and which frameworks do you prefer.

Posted on May 21, 2008 by Mike Jennings in Java | 0 Comments | Permalink