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.

.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 :

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.

FileZilla, the free FTP Solution

Last update : November 21, 2014

On dezember 28th, 2008, I installed the version 3.1.6. of FileZilla, the free FTP solution. I used the preceding version succesfully for several months.

FileZilla is open source software distributed free of charge under the terms of the GNU General Public License. Both a client and a server are available. It supports FTP, SFTP, and FTPS (FTP over SSL/TLS). The client is available under many platforms, binaries for Windows, Linux and Mac OS X are provided.

My latest installed version is 3.9.0.6,  released October 20, 2014.

EC2 : Amazon Elastic Compute Cloud

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers.

Amazon EC2 reduces the time required to obtain and boot new server instances to minutes, allowing to quickly scale capacity, both up and down, as the computing requirements change. Amazon EC2 provides developers the tools to build failure resilient applications and isolate themselves from common failure scenarios.

Amazon EC2 presents a true virtual computing environment, allowing you to use web service interfaces to launch instances with a variety of operating systems, load them with your custom application environment, manage your network’s access permissions, and run your image using as many or few systems as you desire.

To use Amazon EC2, an Amazon Machine Image (AMI) containing the applications, libraries, data and associated configuration settings is created or a pre-configured and templated image is used to get up and running immediately. The AMI is loaded into Amazon S3.

Amazon EC2 is elastic (scalable), flexible, completely controlled, designed for use with other Amazon Web Services, reliable, featured for Building Failure Resilient Applications (Amazon Elastic Block Store, Multiple Locations, Elastic IP Addresses), secure, inexpensive.

The default instance is a 32-bit platform with 1.7 GB of memory, 1 compute unit and 160 GB of instance storage (small instance). Large, extra-large and high-CPU instances are available for compute-intensive applications.Price:

The price for using a small instance is $0.10 per instance hour for Linux and $0.125 per instance hour for Windows. Amazon EC2 uses a variety of measures to provide each instance with a consistent and predictable amount of CPU capacity. Understanding the EC2 price model is not easy and several questions in the AWS forum refer to this issue. Here are some answers :

If you start an instance once every 24 hours and run it for less than an hour, and do this every day for a 30-day month, you will be charged for 30 instance hours.  As long as your instance is running, it is billable at the rate for that instance. A website would not be publicly available if the instance is not running. To run a website available 24/7 in a month, it will cost about $90 for windows instance-hours + storage charge + data in/out charge + others.

One customer confirmed the price calculation and stated that he compared AWS pricing with that of other companies. Although there were several companies that offered hosting for cheaper, in the end he decided to start using EC2 for the following reasons :

Although those sites were cheaper, none of them gave him as much flexibility as he wanted. He had to use their preset hosting configurations, which wasn’t very condusive towards hiswebsite-model. Similar cloud offerings, such as the ones offered by RackSpace, actually ended up being more expensive in the end. But most importantly, he could take advantage of Amazon’s other web services as well.  The one he was most excited about is Amazon Cloudfront to get a full-fledged content delivery service in one easy-to-use package.  Thats one offering that those “$9.99 a month!” companies can’t offer, and it’s something he needs.

There are other providers offering elastic computing power :

Zen Cart : The Art of E-Commerce II – Installation

Version 1.3.8a of the free open source shopping cart software “Zen Cart” can be downloaded from the official website. The installation guide is available at the same site in the tutorials section, a basic checklist to set up the shop and get it operational is included in the wiki section.

I installed a demo-version at my site www.web3.lu in the folder store_demo . I used the FTP program FileZilla to upload the software. The database can be managed with dbadmin. The MySQL version is 4.0.13.

After starting the installation, I received the error message that CURL is not compiled into PHP. CURL is required by some payment and shipping modules in order to talk to an external server to request real-time quotes or payment authorizations. An alert indicates that “Register Globals = ON”. Zen Cart™ can work with the “Register Globals” setting on or off. However, having it “off” leaves your system somewhat more secure. Another error message indicates that “PHP Safe Mode = ON”. Zen Cart™, being a full-service e-Commerce application, does not work well on servers running in Safe Mode. Two other alerts indicate for information that “PHP open_basedir restrictions = /www/provider/sarapro/pages” and that “PHP Output Buffering (gzip) = OFF”.

The database server is “ptmysql.pt.lu”, the name of the database is “sarapro”, the table-prefix is “store_demo” (to avoid confusions it’s better to end the prefix with _). Database sessions are stored in the database, the SQL cache method is set to “none”.

The physical path to Zen Cart™ is “/www/provider/sarapro/pages/store_demo”, the URL is “http://www.web3.lu/store_demo”. SSL is not activated. The phpBB forum is not installed.

The following initial values have been entered for the store setup:

  • Store Name : ARTGALLERY DEMO
  • Store Owner : Sara Proft
  • Store Owner email : alipa@saraproft.com
  • Store Country : Luxembourg
  • Store Zone : Alabama (Europe, default, nothing or Luxembourg does not exist)
  • Store Address :ARTGALLERY DEMO 36, rue Vullesang L-4853 Rodange Luxembourg
  • Default Language : English
  • Default Currency : Euro
  • Store Demo : yes
  • ZenCart update : no

I declared myself as administrator. After the succesful installation, I changed the proprieties of the config files on the server to “read only” and I deleted the install-folder for security reasons. The store setup values are registered in the config files. Congratulations: the demo-shop is working as expected.

Following tables have been created in the database sarapro (with the prefix store_demo) :

  • address_book
  • address_format
  • admin
  • admin_activity_log
  • authorizenet
  • banners
  • banners_history
  • categories
  • categories_description
  • configuration
  • configuration_group
  • counter
  • counter_history
  • countries
  • coupon_email_track
  • coupon_gv_customer
  • coupon_gv_queue
  • coupon_redeem_track
  • coupon_restrict
  • coupons
  • coupons_description
  • currencies
  • customers
  • customers_basket
  • customers_basket_attributes
  • customers_info
  • customers_wishlist
  • db_cache
  • email_archive
  • ezpages
  • featured
  • files_uploaded
  • geo_zones
  • get_terms_to_filter
  • group_pricing
  • languages
  • layout_boxes
  • manufacturers
  • manufacturers_info
  • media_clips
  • media_manager
  • media_to_products
  • media_types
  • meta_tags_categories_description
  • meta_tags_products_description
  • music_genre
  • newsletters
  • nochex_apc_transactions
  • nochex_sessions
  • orders
  • orders_products
  • orders_products_attributes
  • orders_products_download
  • orders_status
  • orders_status_historystore_demoorders_total
  • paypalstore_demopaypal_payment_status
  • paypal_payment_status_history
  • paypal_session
  • paypal_testing
  • product_music_extra
  • product_type_layout
  • product_types
  • product_types_to_category
  • products
  • products_attributes
  • products_attributes_download
  • products_description
  • products_discount_quantity
  • products_notifications
  • products_options
  • products_options_types
  • products_options_values
  • products_options_values_to_products_options
  • products_to_categories
  • project_version
  • project_version_history
  • query_builder
  • record_artists
  • record_artists_info
  • record_company
  • record_company_infostore_demoreviews
  • reviews_description
  • salemaker_sales
  • sessions
  • specials
  • tax_class
  • tax_rates
  • template_select
  • upgrade_exceptions
  • whos_online
  • zones
  • zones_to_geo_zones

I tried to install the product type book from Paul Hailey. When I run the SQL patch to create the book product tables, I receive the error message “1064 You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ENGINE=MyISAM’ at line 1
in: [CREATE TABLE store_demobook_authors”.

To fix this problem, I run the following example to test the syntax with success :

CREATE TABLE shop (
article INT(4) UNSIGNED ZEROFILL DEFAULT ‘0000’ NOT NULL,
dealer  CHAR(20)                 DEFAULT ”     NOT NULL,
price   DOUBLE(16,2)             DEFAULT ‘0.00’ NOT NULL,
PRIMARY KEY(article, dealer));
INSERT INTO shop VALUES
(1,’A’,3.45),(1,’B’,3.99),(2,’A’,10.99),(3,’B’,1.45),
(3,’C’,1.69),(3,’D’,1.25),(4,’D’,19.95);

The table store_demoshop was created with the correct values.

After deleting the default statement ENGINE=MyISAM, the patch was executed correctly and 169 statements have been processed. The following additional tables have been created in the database sarapro:

  • book_authors
  • book_authors_info
  • book_color
  • book_color_description
  • book_condition
  • book_condition_description
  • book_genre
  • book_genre_description
  • book_type
  • book_type_description
  • book_dd1
  • book_dd1_description
  • book_dd2
  • book_dd2_description
  • book_dd3
  • book_dd3_description
  • book_dd4
  • book_dd4_description
  • book_dd5
  • book_dd5_description
  • book_dd6
  • book_dd6_description
  • books_to_authors
  • books_to_genres
  • books_to_types
  • books_to_languages
  • books_to_dd1
  • books_to_dd2
  • books_to_dd3
  • books_to_dd4
  • books_to_dd5
  • books_to_dd6
  • product_book_extra

Finally I added the auction product type developped by Bramnick which is available at the Free Software Addons on the ZenCart website. After uploading the additional files, the SQL patch processed succesfully 17 statements.