The Source for Java Technology Collaboration
User: Password:



Kirill Grouchnikov

Kirill Grouchnikov's Blog

Showing licenses for your application

Posted by kirillcool on August 13, 2005 at 08:46 AM | Comments (11)

Most of the nowadays open-source and commercial products extensively use other products. Although the "not invented here" syndrome is infective, things such as look-and-feel, layout managers, graph libraries, reporting tools etc. are taken from well-known and actively maintained third party sites. These tools come in variety of licenses, most of which require you to include the corresponding licenses along with the executable version of your own library. Here is a graphical way to organize all licenses in one user-friendly window.

Here is a screenshot of license viewer for JAXB Workshop that uses ten other libraries (click screenshot to view full-scale version):

The left panel shows tree with all third-party libraries (the root is your own library). Libraries can be grouped (in screenshot above, JUNG library uses three other libraries, which are grouped under it). Each tree entry shows the library name and the license abbreviation. Clicking on a tree entry shows the corresponding license in the right text pane, along with the library name, library URL and license full name above the license.

The source for the license viewer can be found in the CVS repository at this link. Sample code for using the license viewer is:
    
LicenseDialog licenseDialog = new LicenseDialog(
  ownerFrame,      // your application frame
  "JAXB Workshop", // library name
  new LicenseDialog.LibraryDetails(
    "https://jaxb-workshop.dev.java.net/", // library URL
    LicenseDialog.LicenseType.BSD,         // license enum
    "license/bsd_license.txt"));           // resource name for license text
The license viewer comes with about ten pre-defined licenses (such as Apache, BSD, LGPL etc.), which can be referenced using enum value as above. For licenses that are not pre-defined:
     
licenseDialog.addNewRootLibrary(
  "SJSXP",  // library name
  new LicenseDialog.LibraryDetails(
    "https://sjsxp.dev.java.net/",                   // library URL
    "Sun BCL",                                       // license abbreviation
    "Sun Binary Code License",                       // license full name 
    LicenseDialog.LicenseType.getLicenseIcon("10"),  // icon for license entry in the tree
    "license/sun_bcl_license.txt"));                 // resource name for license text
The license viewer provides a helper function for creating standard-looking icon (getLicenseIcon used above). For defining library groups:
     
licenseDialog.addNewChildLibrary(
    "JUNG",                   // parent library name
    "Commons Collections",    // library name
    new LicenseDialog.LibraryDetails(
      "http://jakarta.apache.org/commons/collections/",   // library URL
      LicenseDialog.LicenseType.APACHE2,                  // license enum
      "license/apache2_license.txt"));                    // resource name for license text
As can be seen, you are responsible for bundling the license text itself as a resource with your application.
     
licenseDialog.expandAll(true);
licenseDialog.setLicenseTextAreaFont(
   new Font("Tahoma", Font.PLAIN, 12));
These two functions expand all branches in the license tree and set font for the license text pane. Finally, set preferred size and location for the license viewer and show it:
     
Dimension dim = new Dimension(800, 600);
licenseDialog.setSize(dim);
licenseDialog.setPreferredSize(dim);
licenseDialog.setResizable(false);
licenseDialog.pack();
licenseDialog.setLocation(...);
licenseDialog.setVisible(true);
You can see the license viewer in action by WebStarting this link (requires JVM 5.0+) and going to Help -> View licenses.

The next logical step would be to create a new project on java.net that will provide such viewer along with bundled versions of most-popular licenses. Volunteers (a slight chance to win immortal glory is implicitly guaranteed)?

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • You probably should add support to pull library licenses from Maven's repository using their POM data. I believe these guys have some Mojo (sort of standalone plugin) that does all work for loading POM's from the repository (e.g. ibiblio) and parsing them.

    Posted by: euxx on August 13, 2005 at 09:30 AM

  • The next logical step would be to create a new project on java.net

    I won't be doing that , but I have a more modest contribution: isn't "Binary" mispelled as "Bindary" in your code?

    -- Felipe

    Posted by: felipeal on August 13, 2005 at 11:21 AM

  • Thanks, Felipe. Will be fixed.

    Posted by: kirillcool on August 13, 2005 at 11:23 AM

  • Can someone please explain why an own component and even an own project is needed for this? What's so difficult and so special with licenses that they can't be displayed with this thing: http://java.sun.com/products/javahelp/

    Posted by: ewin on August 15, 2005 at 01:25 PM

  • NIH syndrome comes to mind :)

    Posted by: jwenting on August 16, 2005 at 11:08 PM

  • The Netbeans builder badly needs such a license agreement viewer. Sooner the better. Is someone from the legal team listening?

    Posted by: bharathch on August 17, 2005 at 03:40 AM

  • I've downloaded the code into an eclipse java project as a single file LicenseDialog.java but it will not compile.

    The inner classes cannot resolve the LicenseType enum that is defined in the parent class (LicenseDialog). It appears to be a very simple problem, but I cannot fix it. I've tried a complete path to the LicenseType to no avail... it just does not like that static enum... any suggestions?

    Posted by: cavalleydude on August 24, 2005 at 09:12 AM

  • What version of Eclipse are you using, how did you define "compiler compliance level" and what JDK are you using? This works under Eclipse 3.1-3.2 and IDEA 4.5-5.0 (under JDK 5.0-6.0) for me.

    Posted by: kirillcool on August 24, 2005 at 09:16 AM

  • Using Eclipse3.1.0 and JDK1.5.0_04 with Compliance 1.5 with default compliance settings

    Posted by: cavalleydude on August 24, 2005 at 11:26 AM

  • I just looked up the Eclipse website, this appears to be an Eclipse 3.1.0 problem with static enums. I'll upgrade then re-test, I think that will do it.

    Posted by: cavalleydude on August 24, 2005 at 11:40 AM

  • I installed Eclipse 3.2 M1, it works fine now. So, it looks like this static enum problem is corrected in later versions of 3.1.

    Posted by: cavalleydude on August 24, 2005 at 12:34 PM





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