Platinum Solutions Corporate Website

Mark Toscano's blog

Using JSON with JavaScript

JSON (JavaScript Object Notation) is a light weight data interchange format alternative to using xml with Ajax.  It is a subset of the JavaScript object literal notation that which is basically made of 2 object types.  The first being a collection of name value pairs similar to a hash table.  An ordered list of values is the other, basically representing an array.  The following shows how to write a JSON object in JavaScript and access it.

    var company = {
        name: "Software Inc.",
        employees: [
        {
            name: "Mike",
            skill: "Java"
        },
        {
            name: "Joe",
            skill: "HTML"
         },
        {
            name: "Betty",
            skill: "C++"
        }
        ]
    };

    // Access the data
    var employee2 = company.employees[1];

All in One Executable Jar using One-JAR

Trying to create an all in one executable jar can present some problems.  One of the main problems is trying to resolve support jar files within the application jar.  Running executable jars with java –jar will only load resources in the root of the jar and ones specified in the manifest class path attribute.  Unfortunately it cannot load jars within a jar.  One commonly used solution is to unjar all supporting libraries and put the flattened out classes in a single directory then jar up all the files.  This can lead to name conflicts and other issues.  One-JAR helps solve this problem and allows you to put supporting jars in the main application jar and have them resolved.