Back to Java

I did a bunch of analysis on my last project. The customer wanted more project management. So another guy on the team had to take over, My boss told me to work on a prototype for some data input screens from a legacy system.


Some of the screens are huge. And they have complex validation logic. I fired up my text editor. Wrote some HTML and JavaScript to get the first screen done. That intro screen was small, but it had a ton of validation.


My boss called me up and checked on my progress. He clarified that he wanted me to use Java, Derby, AngularJS, REST, and JBoss EAP.  He said some acceptable alternatives would be Oracle, HTML5, and Eclipse/Tomcat. I went with his recommendations.


I got JBoss Dev Studio with EAP installed on my new laptop. Then I started going through a tutorial from JBoss called Ticket Monster. I was following a pretty detailed tutorial. Things got vague when I was instructed to deploy the H2 console. Err what?


H2 is an in memory database. I went over to the JBoss Developer Materials page. Downloaded the zip file with the H2 console. Unpacked it and found the "h2console.war" file. Dropped that in the \runtimes\jboss-eap\standalone\deployments folder. Now here I am.

JBoss Developer Studio

At work I am starting to spend half my time on a new project. It is an effort to create a web version of our system. It will use the same Oracle back end. However the front end will be developed in Java using JBoss Developer Studio.

JBoss Dev Studio is a rebranded Eclipse IDE. I know Java. However I always use a text editor to force me to learn the syntax and member functions of classes I use. So I am not well versed in Eclipse. This is going to be a long learning curve.

One thing I found out is that if you have a workspace open in one instance of JBoss Dev Studio, you cannot open it in another instance. Makes sense I guess. But I fought with that for a while before I figured it out.

I also learned that you may need to refresh your source tree for any changes in packages that your source supports. Go figure. Finally I found that I installed my software in the wrong order. I initially installed JBoss Dev Studio first. It then made me choose a JRE. Then I installed the latest JDK I wanted to use. Unfortunately I had to figure out how to reconfigure JBoss Dev Studio to use the JDK of choice.

Foiled by MySQL Connector/J Again

All right. I dumped a lot of emails from Amazon to a text file. I parsed that file and have a lot of thousands of Amazon Kindle books that I own. Now I want to add them to a database. I want to stick them in MySQL specifically. So I call on JDBC to do the deed.

I run into the dread error "java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/". Now I have received that error before. I thought the solution was to stick the JAR file with the MySQL JDBC driver in the class path. Nope. That did not do the trick.

For a while I was pulling my hair out, trying to figure this out. Then I went back to an old project where I got this working. Turns out you need to explicitly path the JAR file in the classpath. I had thought you only needed to specify its directory. No. You need the fully qualified path including the JAR filename in the classpath. Go figure.

At least I got a boatload of book titles inserted into a MySQL database table. Now for the really fun part. Time to write a program to find the books on Amazon's web site and scrape some details out.

Web Scraper Revived

Previously I had written about my web scraper project. Well now I am coming back to it. I got a couple thousand eBooks in my Kindle reader. It is tough figuring out what book I should read next each time I finish a book. I manually go through a lot of books, looking up their pages on Amazon. Wouldn't it be nice if I had a program that could help me decide?

First order of business was to get a list of the books. At first I thought I might be able to hack the AZW file format and extract details from the books themselves. Nah. Too hard. Instead I remembered I had an email from Amazon for just about every book I bought. The emails were in Microsoft Outlook 2010. Turns out I could just save the emails as a text file.

Now my first job is parsing this file. I was hoping to get the links to the books on the Amazon site. Nope. That is not stored in the text file output by Outlook. That is okay. I can get the book name. Next I need to figure out how to take that name and programmatically search the Amazon web site for details on the book.

I plan to store my data in a MySQL database I got running on my machine. Right now I extracted all the book names to a text file. Next steps is to instead stick them in a database table. Maybe I will also record when I ordered the book. Then I will want to find and scrape the Amazon page for the book. Good things to grab from Amazon would be book price, date published, author, average customer rating, number of customer reviews, etc. All these goodies could be stored in my database.

Eventually I want to write a function or program that could score the books, predicting which books I should read next. Ahh this is going to be a very fun project indeed.

Pacman Progress

I am nearing the end of my summer project. This is a clone of Pacman written in Java. I think I will stop implementing new features. Just clean up the code. Fix some bugs. Package the thing and call it a summer.

Recently I did a bad thing. I deleted all my Java files. I wanted to delete all my class files. That will teach me to try to compile from the command line. Damn. At least I had a backup that was a week or two old. It still irked me.

Some buggy object code had the game crashing when exceptions were thrown. Now we still need to hunt down the root cause of those bugs. However I managed to keep things running by validating parameters passed into my functions. Prevents evil access problems.

Next thing I might try to slip in there is better timing for the action in the game. Right now I just sleep a hard coded number of milliseconds based on how much processing I figured I expended to render a frame. However I really should just poll the clock to figure out how long to sleep.

Hot Technology

I read an article that surveyed what technologies Java developers were using. Hey. I want to keep up with the Jones. So I am keeping an eye on the top tech in a number of areas. I write them down here so I don't forget.

JUnit for testing.
Eclipse as your IDE.
MySQL or Oracle for the database.
Hibernate is your ORM.
MongoDB for NoSQL.
Jenkins for CI.
Maven to build.
SonarQube/FindBugs/Checkstyle for code analysis.
Nexus to hold artifacts.
Tomcat app server.
Spring MVC is your web framework.
Scala is your next language.
Java8 is coming up.

Okay. Time to get busy making sure I got these technologies under my belt. You got to work with the best, or at least the most popular. Shout out to the makers of JRebel, who I assume came out with the report ranking the technologies.

Wakka Wakka

This week we are taking our video game to the next level. The prototype works good. I decided to make a number of noteworthy additions, including sounds. I had used sampled clips before in Java. I even knew the libraries I needed to include.

So Pacman chomps on a pellet. The game is supposed to make this wakka-wakka sound. I got an audio file that has the sound. Just got to play it each time Pacman goes over a pellet. The first time I tried it out I heard nothing. I figured this could not be right. I played sounds before for my last game.

Then I looked at my game loop. For now we are settling for choppy animation until we get all the mechanics down tight. To prevent the game from running too fast, I sleep() for a second each iteration through the game loop. Turns out you cannot play a clip and sleep immediately afterwards. Drat.

When I finally implement the full animations, hopefully the sound will play fully. For now I just moved my sound playing earlier up in my game loop, giving it some time to execute before the thread sleeps. Next up my partner has to add more AI to make the ghosts "smarter". Currently Pacman can outsmart them and leave them lost.