/* * [Installer.java] * * Summary: run once on install to unpack the Esperanto dictionary jar files. * * Copyright: (c) 2000-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 2.2 2008-04-06 add build to title, tidy code, fix spelling errors. */ package com.mindprod.esper; import javax.jnlp.DownloadService; import javax.jnlp.ServiceManager; import static java.lang.System.*; /** * run once on install to unpack the Esperanto dictionary jar files. * * @author Roedy Green, Canadian Mind Products * @version 2.2 2008-04-06 add build to title, tidy code, fix spelling errors. * @since 2000 */ public final class Installer { /** * main class for the installer, unpacks dictionaries from jars to separate files. * * @param args not used */ @SuppressWarnings( { "EmptyCatchBlock" } ) public static void main( String[] args ) { // copy from jar to separate file: // cache of words previously looked up LocalDict kasxejo; // words we tried looking up before and failed LocalDict nekonato; // local dictionary, from Roedy, Geneva, Ergane LocalDict vortaro; // cache of words previously looked up LocalDict cache; // words we tried looking up before and failed LocalDict unknown; // local dictionary from Roedy, Geneva, Ergane LocalDict mini; // prefixes, not currently used LocalDict prefiksoj; // suffixes, not currently used LocalDict sufiksoj; out.println( "unpacking dicts.jar file..." ); kasxejo = new LocalDict( "kasxejo.dict", true ); kasxejo.open(); kasxejo.save(); kasxejo.close(); nekonato = new LocalDict( "nekonato.dict", true ); nekonato.open(); nekonato.save(); nekonato.close(); vortaro = new LocalDict( "vortaro.dict", true ); vortaro.open(); vortaro.save(); vortaro.close(); unknown = new LocalDict( "unknown.dict", true ); unknown.open(); unknown.save(); unknown.close(); cache = new LocalDict( "cache.dict", true ); cache.open(); cache.save(); cache.close(); mini = new LocalDict( "mini.dict", true ); mini.open(); mini.save(); mini.close(); prefiksoj = new LocalDict( "prefiksoj.dict", true ); prefiksoj.open(); prefiksoj.save(); prefiksoj.close(); sufiksoj = new LocalDict( "sufiksoj.dict", true ); sufiksoj.open(); sufiksoj.save(); sufiksoj.close(); try { DownloadService ds = ( DownloadService ) ServiceManager .lookup( "javax.jnlp.DownloadService" ); // no longer need associated Jar file ds.removeResource( new java.net.URL( "dicts.jar" ), null ); } // all kinds could go wrong, UnavailableServiceException, // MalformedURLException, IOExeception, // no web start classes available. catch ( Exception e ) { } } }