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.

ImageMagick & PerlMagick

ImageMagick® is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in over 100 formats. ImageMagick can translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems and offers an iterface to most programming languages (Java, php, Perl, Pascal, Ruby, Python, C++, …).

The Definitive Guide to ImageMagick explains all of these capabilities and more in a practical, learn-by-example fashion, the book ImageMagick Tricks by Sohail Salehi is a fast-paced and practical tutorial packed with examples of photo manipulations, logo creation, animations, and complete web projects.

PerlMagick is an objected-oriented Perl interface to ImageMagick. This module can read, manipulate and write an image or image sequence from within a Perl script. This makes it very suitable for Web CGI scripts. I created the following test script on my hosted webserver to verify the correct configuration of ImageMagick and PerlMagick.

#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use Image::Magick;
# created by Marco Barnig on 6th january 2009

my $headline = “Perl Test Script test9.pl”;

print “Content-type: text/htmlnn”;
print ‘<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>’, “n”;
print “<html><head><title>Perl Test</title></head><body>n”;
print “<h1>$headline</h1>n”;
print “<p>This test script opens an image file test.jpg, makes a clone, modify it and save it as mynew.gif</p>n”;

my $image1 = new Image::Magick;
my $status = $image1->Read( “../../httpdocs/media/test.jpg” );
die “Couldn’t open file test.jpg !” if “$status”;
my $image2 = $image1->Clone();
#blah, do something to $image2
$image2 -> Draw (
stroke    => “red”,
primitive => “line”,
points    => “20,20 180,180”);
my $status3 = $image2->Write( “gif:../../httpdocs/media/mynew.gif” );
die “Couldn’t save file mynew.gif in folder httpdocs/media !” if “$status3”;
print “<img src=”http://www.artgallery.lu/media/logo.gif”></img>n”;
print “<br/><br/>”;
print “<img src=”http://www.neen.lu/media/mynew.gif”></img>n”;
print “<br/><br/>”;
print “Das Script ist fertig”;
print “</body></html>n”;

.htpasswd & .htaccess on webservers

Apache and other webservers lets you password protect individual files, folders, or your entire website fairly easily with .htpasswd and .htaccess.

To password protect a folder on your site, you need to put the following code in your .htaccess file:

AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName “My Secret Folder”
Require valid-user

The path /full/path/to/.htpasswd should be the full path (the path to the file from the Web server’s volume root) to a text file called  .htpasswd uploaded in a folder outside of the web root, if possible.

The textfile .htpasswd contains the following informations, separated by a colon (:)

username:encryptedpassword

It’s possible to include multiple users in the .htpasswd file.

To encrypt the password, you can use free webtools like

or  the htpasswd utility that comes with Apache.

More details are available in the following tutorial.

cgi & perl

The Common Gateway Interface, or CGI, is a standard for external gateway programs to interface with information servers such as HTTP servers, maintained by the NCSA. The current version is CGI/1.1 and CGI/1.2 is under progress.

Essentially, a CGI is just a program which runs on the server. It can be written in any programming language, but Perl has become a popular choice for CGI programming because it is available for all platforms, and it has many useful tools that are ideal for the web. By convention cgi programs have the file extension .cgi.

Perl is an interpreted language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It’s also a good language for any system management tasks. The language is intended to be practical rather than beautiful. Perl was created by Larry Wall. Perl scripts have the file extension .pl.

There is no real difference between .cgi and  .pl file extensions. Web servers can be configured for a specific extension or you can even leave off the extension, because it’s the first line called shebang in the script that tells the server where and which interpreter to use. For perl programs I prefer to use the extension .pl.

A typical shebang line for perl is: #!/usr/bin/perl

To let the server know it is a cgi program, the files are generally placed in a special directory on the server called /cgi-bin. For security reasons the webserver does not allow chmod permission settings of 777 or 775 for scripts. I set them to 755.

I use the following reference test perl file to check the correct configuration of my hosted webserver.

#!/usr/bin/perl -w

use strict;
use CGI::Carp qw(fatalsToBrowser);

my $headline = “Perl Reference Script”;

print “Content-type: text/htmlnn”;
print ‘<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>’, “n”;
print “<html><head><title>Perl Test</title></head><body>n”;
print “<h1>$headline</h1>n”;
print “<p>This test script opens a data.txt file, appends a name to it and creates a new file new.txt</p>n”;
print “</body></html>n”;

open (MYFILE, ‘data.txt’) || die “Could not open file data.txt”;;
while (<MYFILE>) {
chomp;
print “$_n”;
}
close (MYFILE);

open (MYFILE, ‘>>data.txt’) || die “Could not write to file data.txt”;;
print MYFILE “Bobn”;
close (MYFILE);

open (MYFILE, ‘>new.txt’) || die “Could not create file new.txt”;
print MYFILE “This file has been createdn”;
close (MYFILE);

The following commands are used to run the program:

  • -w : switch to turning on warnings
  • use strict : pragma for the interpreter to make it harder to write bad software
  • use CGI::Carp qw(fatalsToBrowser) : command to redirect fatal errors such as compiler or other errors to the browser
  • MYFILE : filehandler

A testfile to show my webserver cgi environment variables is available at the following link.  An advanced testfile can be started here. The access is protected with .htaccess and .htpasswd.

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>

Ruby : langage de programmation libre

Ruby est un langage de programmation libre. Il est interprété, orienté objet, et multi-paradigme. Le nom Ruby n’est pas un acronyme mais un jeu de mots avec le langage informatique Perl.

Yukihiro Matsumoto (Matz) est le créateur de Ruby. Ne trouvant pas dans les langages de programmation déjà existants de quoi le satisfaire, il commença l’écriture en 1993 et publia une première version en 1995.

REST : Representational state transfer

Last Update : April 15, 2013

Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The terms were introduced in 2000 in the doctoral dissertation of Roy T. Fielding, one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification.

REST strictly refers to a collection of network architecture principles which outline how resources are defined and addressed. The term is often used in a looser sense to describe any simple interface which transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies. The difference between the uses of the term “REST” therefore causes some confusion in technical discussions.

Systems which follow Fielding’s REST principles are often referred to as “RESTful”.

The claimed benefits of REST are listed in the the free encyclopedia Wikipedia.

Additional informations about REST are available at the following links :

VOXEO hosting platform

Voxeo offers three main application platforms for free to developers: CallXML, CCXML, and VoiceXML.

The Prophecy 8.0 – CallXML 3.0 platform allows developers to build robust IVR applications using only static content. CallXML suits the needs of most telephony applications that use touchtone input (DTMF).

The Prophecy 8.0 – CCXML W3C 1.0 platform allows to deploy the next-generation conferencing/call routing applications to ensure that they will stand the test of time.

The Prophecy 8.0 – VoiceXML 2.1platform includes the Voxeo ASR engine (available only in US English) and is the world’s first and only 100% certified-compliant VoiceXML 2.0 browser. The Prophecy Platform supports all the VoiceXML 2.1 additions and enhancements, as well as the SISR/SRGS grammar formatting standards. It also includes legacy support for the older GSL and JSGF grammar formats.

I created an account a few years ago to do my first trials with VoiceXML. Today I updated the account and started with a new HelloWorld test application. The telephone numbers to access the application are the following:

  • Skype VoIP :  +99000936 9991425592
  • SIP VoIP :  sip:9991425592@sip.voxeo.net
  • iNum Number : +883510001801392

iNum Number from Luxembourg : +352 20880108 p 883510001801392

If calling from a mobile phone (for instance with a BlackBerry) to an iNum number, you have to insert a pause between the local number and the iNum number by using the menu during the number editing.

My first iNum call to the HelloWorld application was succesfully established today at 21h21 with my mobile phone.

iNum : a global phone number of the ITU (+883)

An iNum is a new kind of global phone number that is not tied to any country or location. It uses a new +883 global country code that was recently created by the ITU (International Telecommunication Union). An iNum offers several compelling advantages:

  • It is a global phone number that will be able to be called from anywhere in the world
  • It is a portable phone number in that it is not tied to a specific country
  • Calls to an iNum can be free from some service providers and may be inexpensive from other providers
  • It is reachable from both the traditional Public Switched Telephone Network (PSTN) and also from Voice-over-IP (VoIP) providers

The +883 country code used for iNums is still in the process of being deployed globally across the existing PSTN. As a result, users in some countries may not be able to dial an iNum directly on their existing PSTN carrier. To assist users whose carriers do not yet support the +883 country code, Voxbone, the carrier behind the iNum initiative, has set up local phone numbers in 45 countries. For Luxembourg, this number is +352 20880108. Simply dial this local access number and dial the chosen iNum afterwards.

iNum is an initiative launched by Voxbone, supplier of local telephone numbers to communications services providers and businesses worldwide. Voxbone is a privately held company with offices in Brussels, Singapore and Los Angeles.

An iNum will be automatically assigned to developers of a new application on the free VoiceXML VOXEO platform.

ECLIPSE – an open development platform

Last update : June 29, 2015

Eclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. A detailed overview about the Eclipse software is available at Wikipedia.

I started a year ago to use the EUROPA version (platform 3.3) of Eclipse to develop JAVA applications for the web. I changed  later to the  release GANYMEDE (plaform 3.4.) published in june 25th, 2008. I used the IDE for Java EE Developers (163 MB) with tools for Java developers creating JEE and Web applications.

A tutorial how to create servlets with Eclipse has been published on the Java Tips website. A french tutorial about servlets and jsp pages with Eclipse and Tomcat is available at the website of Serge Tahé (Maître de conférences en Informatique à l’université d’Angers). Another useful tutorial about Struts (méthode de développement gérée par l’Apache Software Foundation qui a pour but de fournir un cadre standard de développement d’applications web en Java respectant l’architecture dite MVC : Modèle – Vue – Contrôleur ) has been edited by the same author.

Other interesting tutorials are listed below :

To integrate my existing Java projects in Eclipse, I created a new Java Project in the Eclipse Workspace, copied the folder with the source files in this new project folder and executed the file – refresh menu.

The Eclipse platform is also used for Android developments, a preconfigured ECLIPSE version is included in the Google Android SDK.

In the context of the OFUR project, I installed in late June 2015 the new Eclipse Mars version (4.5) with the Javascript Development Tools (from the Web, XML, JavaEE and OSGi section), the Eclipse Web Developer Tools and the jshint Tools.

I added my signature files ida_dsa and ida_rsa to the SSH2 settings in the Eclipse – Window – Preferences – General -Network Connections – SSH2 menu. I accepted the default location for the workspace (users/mbarnig/workspace) and for the local GIT repository (users/mbarnig/git) in the Eclipse – Window – Preferences – Team – Git menu.

To checkout the original code for the DICOM Web Viewer (DWV),  I entered the HTTPS clone URL of the DWV Github front page to the Git Repository in the Eclipse – Window – Show View – Others – Git menu, clicked the Clone a Git Repository action and selected the master branch to start the download of the source code.

The DWV tree was loaded into the local DWV repository. In the root source folder the file eclipse.epf (Eclipse Process Framework Project) produces a customizable software process enginering framework. I imported the .epf file with the menu File – Import – General – Preferences.