Groovy : a dynamic language for the Java platform

Groovy is an agile and dynamic language for the Java Virtual Machine. It builds upon the strengths of Java but has additional power features inspired by languages like Python, Ruby and Smalltalk. Groovy seamlessly integrates with all existing Java classes and libraries and compiles straight to Java bytecode so you can use it anywhere you can use Java. A set of Eclipse plugins that provide Eclipse support for Groovy projects is available (Groovy-Eclipse).

The current stable version is 1.8. Groovy is used among others for the development of plugins for the DLNA media server Serviio.

Opera Mini Simulator and Opera Dragonfly

Last update : August 30, 2012

Opera Mini 4.2 Simulator

Opera Mini 6.5 Simulator

Opera Software ASA gives developers tools needed to build and test HTML content for different devices on their PC’s.

Opera Mobile Emulator is the desktop version of Opera’s smart phone browser. The Opera Mobile Emulator renders pages as close as you can get to how it would look on a real phone. It can be paired with Opera Dragonfly, a great tool to develop and debug web applications.

The Opera Mini Simulator is the online version of Opera’s Mobile Emulator. It can be accessed from any Java-enabled Web browser, or downloaded and run independently. Two versions were available in the past : Opera Mini 4.2,the world’s most popular mobile Web browser, and Opera Mini 6.5. Today Opera Mini 7, the newest version of this browser, is online. All versions are powered by MicroEmulator, a pure Java implementation of Java 2 Micro Edition in Java 2 Standard Edition licensed under LGPL.

Opera is also available as desktop browser for Windows, Mac and Linux, for tablets and for TV sets.

The Opera TV Emulator gives developers the tools needed to build and test HTML5  content for TVs on their PCs, which will emulate the target device’s environment with no need for physical access to the TV, set-top box or Blu-ray player. The Opera TV Emulator offers a direct, easy way to develop, test and debug and can serve as a reference implementation.

OperaDriver and OperaWatir are toolkits used for automating interactions with web browsers. OperaDriver and OperaWatir allow you to drive the Opera browser and emulate user behavior.

ECLIPSE and TOMCAT (web applications)

Apache Tomcat & Eclipse Platform make a great Web development platform. Tutorials about this development environment are available on the following websites:

I use the Tomcat version 5.5.23 as localhost because this version is available on my hosted website provided by my ISP Visual Online. My Eclipse version is Galileo (3.5.2). The Java SDK is 1.6.

Web applications are deployed on the Tomcat server with a WAR file (which stands for “web application archive” ) A WAR file is a ZIP file used to distribute a collection of JavaServer Pages, servlets, Java classes, XML files, tag libraries and static Web pages that together constitute the Web application.

There are special files and directories within a WAR file.

  • The /WEB-INF/classes directory contains the .class files (servlets, …)
  • The /WEB-INF/lib directory contains the .jar files with the Java librairies
  • The /WEB-INF directory contains a file named web.xml which defines the structure of the web application

The main elements of the web.xml file are shown below :

<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app id=”WebApp_ID” version=”2.4″ xmlns=”http://java.sun.com/xml/ns/j2ee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”>

<display-name>MyExampleWebProject</display-name>
<description>Describe What the application is doing and add comments</description>

<servlet>

<servlet-name>MyServlet</servlet-name>
<servlet-class>saraproft.com.servlet.FirstApp</servlet-class>
<description>Une application très simple</description>

<init-param>
<param-name>size</param-name>
<param-value>123</param-value>
</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>echo</url-pattern>
</servlet-mapping>

</web-app>

The elements of a web.xml file are :

  • the name of the application : <display name>
  • the name, class and parameters of the servlet : <servlet>
  • the mapping of the servlet : <servlet-mapping>
  • context parameters : <context-param>
  • session parameters : <session-config>
  • list of index files : <welcome-file-list>
  • MIME mapping : <mime-mapping>
  • other parameters referring to security, errors, filters, …

The other files (html, jsp, iamges, …) are stored in the root or in folders located in the root of the WAR file. They can’t be included in the WEB-INF directory.

Cellspark animator

Cellspark version 2

The CellSpark animation editor creates compact flash-like vector graphics animations for nearly all Java enabled phones.

Developped by Colin Mummery a few years ago, this tool allows to create presentations, screen savers and more for different handsets.

Runnable midlets can be created for Midp 1 and Midp 2 devices. In 2005, during the Luxembourg Presidency of the Council of the European Union from 1st January till 30th June 2005, I used the licensed version of Cellspark to create a multimedia show about the member states of the European Union as a Midlet for the Nokia handset 6680.

Today, a reinstalled Cellspark (a java program) on my new labtop running Vista and Java 6 without any problems. The program is still very useful, userfriendly and fascinating.

Small Java Web Server

Paul Mutton, who graduated at the University of Kent at Canterbury in 2001 with first class honours in Computer Science (BSc Hons), created  a very small standalone web server written in Java (less than 4 KByte). A more advanced version has less than 10 KByte and is called Jibble Web Server.

The softwares are OSI Certified Open Source Software, available under the GNU General Public License (GPL). Commercial licences are also available.

Other useful Java projects from Paul Mutton are :

JAVA versions

last update : september 2010

If the JAVA versions for development and deployment are different, there is a risk to get the following errors:

  • java.lang.ClassFormatError: ClassName (unrecognized class file version)
  • Exception in thread “main” java.lang.UnsupportedClassVersionError: Bad version number in .class file
  • java.lang.UnsupportedClassVersionError: (Unsupported major.minor version 49.0)

Java has been developed by Sun Microsystems and released in 1995 as a core component of Sun Microsystems’ Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. As of May 2007, in compliance with the specifications of the Java Community Process, Sun made available most of their Java technologies as free software under the GNU General Public License. More details can be found on Wikipedia.
Sun distinguishes between its Software Development Kit (SDK) and Runtime Environment (JRE) (a subset of the SDK); the primary distinction involves the JRE’s lack of the compiler, utility programs, and header files.

The initial version of JAVA was published as JDK 1.0 on 23 january 1996 with the codename OAK.

JDK 1.1. was launched on february 19, 1997 with new features.

Version 1.2. was published on december 8, 1998 with the codename Playground. This and subsequent releases were rebranded Java 2 with the distinctions J2SE (Java 2 Platform, Standard Edition), J2EE (Java 2 Platform, Enterprise Edition) and J2ME (Java 2 Platform, Micro Edition).

J2SE 1.3. was released on may 8, 2000 as Kestrel and included JAVA Sound.

J2SE 1.4. was published on february 6, 2002 with the codename Merlin and included Java Web Start, 18 updates have been released for this version.

Originally numbered 1.5, the Java version released on september 30, 2004, called Tiger, was named J2SE 5. 17 updates have been released for this version.

The latest Java Version, SE 6, (codename Mustang) was published on december 11, 2006. As of this version, Sun replaced the name “J2SE” with Java SE and dropped the “.0” from the version number. The current update is version 12.

Java SE 7 with the codename Dolphin is in the early planning and development stages and is tentatively scheduled for release in 2010.

The Java Business Support road map is available at the Sun website.

The Java Class File Disassembler javap gives the version of a compiled Java class. The major version number correspondance is indicated in the following table :

45 :arrow: Java 1.0 / 1.1
46 :arrow: Java 1.2
47 :arrow: Java 1.3
48 :arrow: Java 1.4
49 :arrow: Java 5.0
50 :arrow: Java 6

Another possibility to identify the java version is to inspect the class file with an Hex-editor. The major version number is stored in the 6th and 7th byte of the file.

To show the installed java version on a server, the following code can be used :
String maxVersion = System.getProperty(“java.class.version”)

An example of a servlet displaying the java version of my hosted Tomcat server is linked here.

Here is a link to show whether Java is working on your computer and to display the installed Java version.

Processing and Eclipse

Last update : January 21, 2014

Processing is an open source programming language and environment for people who want to program images, animation, and interactions. It is used by students, artists, designers, researchers, and hobbyists for learning, prototyping, and production.

Processing is an open project initiated by Ben Fry and Casey Reas. It evolved from ideas explored in the Aesthetics and Computation Group at the MIT Media Lab. Development of Processing began formally in the Spring of 2001, the first alpha release 0001 was used in August 2001, the version 1.0 was released on 24th November 2008, a few days after the last beta version (release 157). Version 2 was released on September 5, 2013. The current version is 2.1 launched on October 27, 2013.

Processing programs can be easely exported to run on the web as Jas applications to run on Windows, Linux, Mac OS X or Android, as Java applets / Java projects or as Javascript web projects. Processing scripts are called sketches. Sometimes it might be useful to combine a Processing sketch with a general Java project, which is best done in Eclipse.

A tutorial how to use Processing in Eclipse is available on the Processing website. The following code has been saved as file MyEclipseSketch.java and runs succesfully as applet in Eclipse.

import processing.core.*;
public class MyFirstSketch extends PApplet{

public void setup() {
size (400,400);
background(0);
}
public void draw() {
stroke (255);
if (mousePressed) {
line (mouseX,mouseY,pmouseX,pmouseY);
}
}
}

To embed the applet in a webpage, the generated MyEclipseSketch.class file was added to the Processing archive core.jar and I renamed the archive file to eclipse_sketch.jar. The html code to display the applet is very easy :

<html>
<header>
</header>
<body>
<applet code=”MyEclipseSketch.class” archive=”eclipse_sketch.jar”/>
</body>
</html>

Apache Ant Build Tool

Last update : 26 November 2013

Today Apache Ant is the build tool of choice for a lot of java projects because the classical  “make” buildtools like make, gnumake, nmake, jam and others have a lot of wrinkles and limitations.

According to Ant’s original author, James Duncan Davidson, the name Ant is an acronym for “Another Neat Tool”. Later explanations go along the lines of “ants do an extremely good job at building things”, or “ants are very small and can carry a weight dozens of times their own” – describing what Ant is intended to be. The latest version of Apache Ant is 1.9.2, released July 12, 2013.

Apache Ant uses XML to describe the build process and its dependencies, the corresponding file is named by default build.xml.

Ant can be integrated in the universal tool platform Eclipse and in other Integrated Development Environments (IDE).

Sphinx-4 : a Java speech recognizer

Sphinx-4 is a state-of-the-art speech recognition system written in Java. It was created via a joint collaboration between the Sphinx group at Carnegie Mellon University, Sun Microsystems Laboratories, Mitsubishi Electric Research Labs (MERL), and Hewlett Packard (HP), with contributions from the University of California at Santa Cruz (UCSC) and the Massachusetts Institute of Technology (MIT).

Sphinx-4 contains the following demo programs :

  • Hello World Demo: a command line application that recognizes simple phrases
  • Hello Digits Demo: a command line application that recognizes connected digits
  • Hello N-Gram Demo: a command line application using an N-gram language model for speech recognition
  • ZipCity Demo: a Java Web Start technology application that recognizes spoken zip codes and locates the associated city and state
  • WavFile Demo: a simple demo program to show how to decode audio files (e.g., .wav, .au files)
  • Transcriber Demo: a simple demo program showing how to transcribe a continuous audio file that has multiple utterances separated by silences
  • JSGF Demo: a simple demo program showing how a program can swap between multiple JSGF grammars
  • Dialog Demo: a demo program showing how a program can swap between multiple JSGF and dictation grammars
  • Action Tags Demo: a demo program showing how to use action tags for post-processing of RuleParse objects obtained from JSGF grammars
  • Confidence Demo: a simple demo program showing how to obtain confidence scores for result
  • Lattice Demo: a simple demo program showing how to extract lattices from recognition results

A number of tests and demos rely on having JSAPI installed. Sphinx-4 can be combined wit FreeTTS to set up a complete voice interface or a VoiceXML server.

FreeTTS : a Java speech synthesizer

FreeTTS is a speech synthesis system written entirely in Java. It is based upon Flite, a small run-time speech synthesis engine developed at Carnegie Mellon University. Flite is derived from the Festival Speech Synthesis System from the University of Edinburgh and the FestVox project from Carnegie Mellon University.
Free TTS was built by the Speech Integration Group of Sun Microsystems Laboratories.

Possible uses of FreeTTS are:

  • JSAPI (Java Speech API) speech synthesizer
  • Remote TTS Server, to act as a back-end text-to-speech engine that works with a speech/telephony system, or does the “heavy lifting” for a wireless PDA
  • Workstation/Desktop TTS engine
  • Downloadable Web Application (FreeTTS can not be used in an applet)

FreeTTS includes the following demos :

  •  JSAPI/HelloWorld: uses the JSAPI 1.0 Synthesis interface to speak “Hello, World”
  • JSAPI/MixedVoices: demonstrates using multiple voices and speech synthesizers in a coordinated fashion using JSAPI 1.0
  • JSAPI/Player: Swing-based GUI (graphical user interface) that allows the user to monitor and manipulate a JSAPI 1.0 Speech Synthesizer
  • JSAPI/JTime: JSAPI program that uses a limited-domain, high quality voice to tell the time
  • JSAPI/Emacspeak: uses JSAPI 1.0 to provide a text-to-speech server for Emacspeak
  • JSAPI/WebStartClock: JSAPI talking clock that can be downloaded from the web using Java Web Start
  • freetts/HelloWorld: low-level (non-JSAPI) program that speaks a greeting to the world
  • freetts/ClientServer: low-level (non-JSAPI) socket-based TTS server with sample clients written in the C programming language and the Java programming language.

To write software with FreeTTS, it is recommended to use the Java Speech API (JSAPI) 1.0 to interface with FreeTTS. The JSAPI interface provides the best method of controlling and using FreeTTS.

Currently, the FreeTTS distribution comes with these 3 voices:

  • a low quality, unlimited domain, 8kHz diphone voice, called kevin
  • a medium quality, unlimited domain, 16kHz diphone voice, called kevin16
  • a high quality, limited domain, 16kHz cluster unit voice, called alan

FreeTTS interfaces with the MBROLA synthesizer and can use MBROLA voices. It’s also possible to import voice data from Festival and FestVox or CMU ARCTIC voices.

A full implementation of Sun’s Java Speech API for Windows platforms, allowing a large range of SAPI4 and SAPI5 compliant Text-To-Speech and Speech-Recognition engines (in many different languages) to be programmed using the standard Java Speech API has been developped by CloudGarden. Packages and additional classes augment the capabilities of the JSAPI by, for example integrating with Sun’s JMF, allowing, amongst other things, MPEG audio files to be created and read, and compressed audio data to be transmitted across a network