NekoBean Paper Craft

, , Comments Off

A few weeks ago, I stumbled on a paper craft template of NekoBean on the nekobean.net website.  The last time I did any art and craft was in junior public school, so I definitely didn’t have the talent for this kind of work.

I printed a few copies using the laser printer at work, and went to work using some white glue and a pair of scissors.

After a few failed attempts and numerous hours I finally put it together!

NekoBean Paper Craft

For readers who aren’t geeks…

What is NekoBean? NekoBean is the mascot for NetBeans introduced by the NetBeans Japanese Speaking Community in Mar 2008.  The actual author is Mutsuki san who seems to be a very talented designer.   The mascot is derived from a cat (“Neko” means “cat” in Japanese), and the NetBeans grid/box logo.

What is NetBeans? Without being too technical, NetBeans is a free software development tool for programming Java, and other programming languages.

If-Else in Ant

, Comments Off

When I need to write quick script to perform a simple task, I opt to use Ant instead of a shell script. Unfortunately, the Ant core tasks doesn’t provide any flow logic like the everyday if-else statements.

Ant-Contrib provides a collection of useful tasks missing in the Ant core.

Installing Ant-Contrib

There are 2 methods to install ant-contrib:

Copy ant-contrib-1.0b3.jar to the lib directory of your Ant installation. If you want to use one of the tasks in your own project, add the lines

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

Keep ant-contrib-1.0b3.jar in a separate location. You now have to tell Ant explicitly where to find it e.g. a lib directory relative to the build.xml

<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="lib/ant-contrib-1.0b3.jar"/>

Example Using If-Else Task

<if>
  <equals arg1="${status}" arg2="OFFLINE"/>
  <then>
    [...]
  </then>
  <else>
    [...]
  </else>
  </if>

SSH with a Web Browser

, 1 Comment »

A while back, I was using someone’s computer and I wanted to SSH into my server. The machine didn’t have any SSH client and I didn’t have my U3 Smart Drive with me.

MindTerm is a client that implements the SSH protocols written in Java which can run as an Applet. The basic syntax for embedding the MindTerm Applet in a web page is as follows:

<APPLET CODE="com.mindbright.application.MindTerm.class"
      ARCHIVE="mindterm.jar" WIDTH="400" HEIGHT="400">
    <PARAM NAME="cabinets" VALUE="mindterm.cab">
    <PARAM NAME="sepframe" value="true">
    <PARAM NAME="debug" value="true">
</APPLET>

Due to the Java security model, the Applet requires to be sign, otherwise it won’t run properly and throw an AccessControlException, as shown in the Java console.

MindTerm AccessControlException

For information on how to sign an Applet refer to Signing Java Applets Using RSA Certificate. After the Applet has been successfully signed a pop up will appear asking to accept the digital signature, and when accepted the Applet will have permission to run properly; this can be verify with the Java console again.

MindTerm Digital Signature

MindTerm Granted Permission

Now you can SSH from any computer that has a web browser and internet access.

MindTerm Applet

For more information refer to Running MindTerm as an Applet

Sending Email with Ant

, Comments Off

Sometimes it’s useful for an Ant script to send out an email. This can be easily done using the mail task which is part of the Core Tasks in Ant. Before using the mail task, the JavaBean Activiation Framework jar file (activation.jar), and JavaMail jar file (mail.jar) needs to be copied into the Ant lib directory. Here is a mail task example which sends an email using a GMail account.

<target name="sendmail">
  <mail
    tolist="nobody@gmail.com"
    from="nobody@gmail.com"
    subject="Email subject"
    mailhost="smtp.gmail.com"
    mailport="465"
    ssl="true"
    user="nobody@gmail.com"
    password="password">
    <message>Example email sent by Ant Mail task.</message>
  </mail>
</target>

Troubleshooting Ant mail task in Ubuntu

Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer not found in java.net.URLClassLoader

If you downloaded Ant from the Ubuntu packages repository, not all the core Ant tasks are available. Download and extract Ant from the Apache Ant website.

$ wget http://www.apache.org/dist/ant/binaries/apache-ant-1.7.0-bin.tar.gz
$ tar -zxvf apache-ant-1.7.0-bin.tar.gz

Copy the ant-javamail.jar into the lib directory of the Ubuntu Ant installation

$ cp ./apache-ant-1.7.0/lib/ant-javamail.jar /usr/share/ant/lib

Failed to send email: could not instantiate ssl security provider, check that you have JSSE in your classpath

If the ssl attribute is set to true, then the Java Secure Socket Extension (jsse.jar) jar file is required, which is already part of J2SE 1.4.x and later. Ubuntu uses GNU Compiler for Java (gcj) as the default JVM which doesn’t have JSSE as the part of the distribution, therefore the jsse.jar file needs to be copied into the Ant lib directory. An alternative solution is to set the default JVM to use another Java distribution which already has JSSE bundled.

Problem using MySQL JDBC on Tomcat 5.5 and Ubuntu 8.04

, , , Comments Off

Normally when I build a web application that connects to a MySQL database, I would place the mysql-connector-java-bin.jar file into the WEB-INF/lib of the web application.

However, when I deployed the application on Tomcat 5.5 on Ubuntu 8.04 I got an exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I couldn’t find the reason which caused the exception, so I did a quick fix by placing the jar file into the Tomcat’s common lib directory.

$ cp mysql-connector-java-bin.jar /usr/share/java
$ cd /usr/share/tomcat5.5/common/lib
$ ln -s ../../../java/mysql-connector-java-bin.jar mysql-connector-java-bin.jar

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in