Category: Java

Interesting: Java Application Store

I saw this post the other day.  Sun is coming out with a Java store to deliver applications.  These stores are getting to be a trend!  I have a “Market” for my Android phone.  iPhone has the same type of thing.  Linux has the repositories of packages, which though you can’t purchase programs, you can easily install programs in much the same way.

Right now, it looks like the store is just in beta.  I am curious to see how this works and how it catches on.

Resources

Adding a Project to Git and Google Code

This started because I wanted to share a program I had been working on through Google Code.

First, I created the git repository by:

skp@pecan:~/app/workspaces/pscompare$ cd ProjectSarah/
skp@pecan:~/app/workspaces/pscompare/ProjectSarah$ ls
bin  derby.log  export.xml  lib  src  timedb
skp@pecan:~/app/workspaces/pscompare/ProjectSarah$ git init
Initialized empty Git repository in /home/skp/app/workspaces/pscompare/ProjectSarah/.git/
skp@pecan:~/app/workspaces/pscompare/ProjectSarah$ git add .
skp@pecan:~/app/workspaces/pscompare/ProjectSarah$

Then, I did a commit:

skp@pecan:~/app/workspaces/pscompare/ProjectSarah$ git commit -m “First Release”Created initial commit 87fa855: First Release
196 files changed, 3456 insertions(+), 0 deletions(-)
create mode 100644 .classpath
create mode 100644 .project
create mode 100644 bin/com/skp/ProjectSarah/ChangeClientButton.class
create mode 100644 bin/com/skp/ProjectSarah/ClientListener.class
create mode 100644 bin/com/skp/ProjectSarah/CreateTimeViewExcel.class
create mode 100644 bin/com/skp/ProjectSarah/CreateTimesheetsButton.class
create mode 100644 bin/com/skp/ProjectSarah/DateField.class

Now, I created a new directory and started following these directions.  One of the problems I had was logging in.  I had to use the “My Profile” link on the upper right hand corner of Google Code.  That showed what my username was, and then, the password was on the Settings tab.

mkdir ~/app/git-workspace
cd ~/app/git-workspace
git svn clone –username <username> https://project-sarah.googlecode.com/svn/trunk
cd trunk
git fetch ~/app/workspaces/pscompare/ProjectSarah/
git branch tmp $(cut -b-40 .git/FETCH_HEAD)
git tag -a -m “Last fetch” last tmp
INIT_COMMIT=$(git log tmp –pretty=format:%H | tail -1)
git checkout $INIT_COMMIT .
git commit -C $INIT_COMMIT
git rebase master tmp
git branch -M tmp master
git svn dcommit

Now, I was able to browse the source of my program online!

Resources

git branch tmp $(cut -b-40 .git/FETCH_HEAD)

Java + Compiz

I have been having trouble with getting blank Windows with my Java programs.  The problem first appeared in programs I was working on in Eclipse, but then I found other programs I had downloaded from SourceForge also had the same problem.  Apparently, the problem comes from a conflict with Compiz-Fusion and Java.

Here is the solution:

Add the following line to /etc/environment —

AWT_TOOLKIT="MToolkit"

You possibly need to reboot for this change to take effect.

When I did this I got this error:

java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-6-openjdk/jre/lib/i386

The problem appears to be caused by using OpenJDK.  The solution was to use Sun’s JDK.  This post will not go into detail about how to switch, but here are some things to consider:

  • Install Sun’s JDK with Add/Remove Programs, apt-get, etc.
  • Use update-alternatives to point the OS to the correct Java Home
  • Run java -version to check that the correct version is in use
  • Update the installed JVMs in the Eclipse preferences to make sure that Eclipse is lauching programs with the correct JVM

Resources

Jasper Reports

I have found Jasper Reports to be a great tool for allowing printing from Java-based applications.  I am using the iReports tool to create the reports in a GUI mode much like Crystal Reports.  Then, with a few lines of Java, I can display the report to view the report and allow him to print.

Jasper Reports Home Page

iReport Home Page

SourceForge Page

Right now, I am trying to figure out how to display totals on the page.  I found this nice article explaining the basics:

Open Source Reporting with JasperReports and iReports (Totals on Page 3)