The Source for Java Technology Collaboration
User: Password:



Francois Orsini's Blog

April 2006 Archives


Embedding Apache Derby in Mozilla Firefox demo posted

Posted by forsini on April 29, 2006 at 11:34 PM | Permalink | Comments (4)

This demo showcases Java DB (based on Apache Derby) running embedded within a web browser.

At the present time, this demo runs on Mozilla Firefox and Mozilla Navigator web browsers - The HTML and javascript would have to be modified in order to run on other web browsers such as Microsoft Internet Explorer.

This Web application demonstrates how an embedded database can be used to persist data from a tax return being created either online or offline. The application can be deployed manually or automatically using Sun's Java Plug-in with installing the application as a Java Extension.

Apache Derby will run embedded within the browser and act as a local storage and cache for this last one.

You can now get all the information about the demo embedding JavaDB within a web browser, which was shown at ApacheCon 05'.

Direct link to the demo information page can be found at http://developers.sun.com/prodtech/javadb/overview/product_tour/index.jsp.

The minimal requirement for the demo is to install Sun's Java plug-in extension for the web browser. This demo does not run on Apple Mac OS X yet (work in progress).

You can also read some additional information on a previous blog entry.



Compressing Apache Derby w/ Pack200

Posted by forsini on April 29, 2006 at 11:26 PM | Permalink | Comments (3)

PACK200 (JSR-200) is a very interesting feature that is available as part of Java 5.

In order to increase network server, availability and bandwidth , two new compression formats have been made available to Java deployment of applications and applets: gzip and Pack200.

HTTP compression is implemented in Java Web Start and Java Plug-in in compliance with HTTP 1.1 RFC 2616. If a client does not support this type of compression then a web server will send a non-compressed JAR or a format that the client can process.

More information about Pack200 at:
http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/pack200.html

I have compressed the Apache Derby engine JAR file (derby.jar) using pack200 and the resulting JAR went from 2,131,777 to 630,520 bytes (~2MB down to 600K for the database core engine!). Uncompression happens on the client side automatically once the pack200 compressed JAR has been fetched.

To compress/pack the JAR archive:
$ pack200 derby.jar.pack.gz derby.jar

It then can be stored on a HTTP 1.1 compliant web server and if a web client support pack200-gzip encoding (specified as part of the HTTP request), then the server will send that compressed JAR down - otherwise the server will stream/send a format that the client can process (compressed {gzip} or not {.jar}).

To unpack (manually):
$ unpack200 derby.jar.pack.gz derby.jar (the unpack operation is actually pretty fast)

This is quite good when one needs to deploy Apache Derby over a network (i.e. Applet using Derby with the Java plug-in, etc) or as part of some installer who would want to pack JARs even more efficiently and then unpack them during install (unpack200{.exe} is a standalone executable that can be included as part of an installer)

pack200 and unpack200 are pure executable(s) that do not require a JVM to be present or run at the time an archive is compressed or uncompressed (i.e. during installation)

unpack200 (Unix) or unpack200.exe(Windows) included as part of the JRE as well (under bin)

Pack200 also has a Java API (java.util.jar.Pack200):
http://java.sun.com/j2se/1.5.0/docs/api/java/util/jar/Pack200.html
The packer engine is used by application developers to deploy or host JAR files on a website. The unpacker engine is used by deployment applications to transform the byte-stream back to JAR format.

This does not reduce the runtime footprint of Apache Derby - it basically provides means to reduce the network footprint of JARs during download. Pack200 also supports the packing of *signed* JARs.





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds