⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jnlp2package.java

📁 JDesktop Integration Components (JDIC)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is * subject to license terms. *  * This program is free software; you can redistribute it and/or modify * it under the terms of the Lesser GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. */ package org.jdesktop.jdic.packager.impl;import java.io.File;import java.io.IOException;import java.net.URL;import java.net.MalformedURLException;import java.util.Iterator;/** * This class generates an platform dependent installable package with the given * arguments. * <p> * On Windows, the generated package is in msi format. * <p> * On Linux, the generated package is in rpm format. * <p> * On Solaris, the generated package is in pkg format. * */public final class Jnlp2Package {    /**     * Jnlp2Packager creator.     *     */    private Jnlp2Package() {    }    /**     * Checks boolean properties and reports errors for illegal     * values(not true or false).     * @param propertyName The given property name.     * @return True if the property contains valid value.     */    private static boolean getBoolProperty(String propertyName) {        String propertyValue = System.getProperty(propertyName);        boolean retValue = false;        if (propertyValue == null) {            retValue = false;        } else {            if (propertyValue.equalsIgnoreCase("true")) {                retValue = true;            } else if (propertyValue.equalsIgnoreCase("false")) {                retValue = false;            } else {                throw new IllegalArgumentException(                    "The value of property " + propertyName                    + " can only be either true or false.");            }        }        return retValue;    }    /**     * Checks all the input arguments in the command line, and returns     * a JnlpPackageInfo object containning the package related information.     * <p>     * The JnlpPackageInfo object will be used to generate a installable     * package.     *     * @param args Arguments to be parsed.     * @return The parsed JnlpPackageInfo.     * @throws IOException If failed to parse the arguments.     */    private static JnlpPackageInfo parseArguments(String[] args)            throws IOException {        String version = null;        String release = null;        boolean showLicense = false;        String licenseDirName = null;        String bannerJpgFileName = null;        String panelJpgFileName = null;        boolean shortcutEnabled = false;        boolean associationEnabled = false;        boolean systemCacheEnabled = false;        JnlpPackageInfo pkgInfo = null;                /////////////////////////////////////////////////////////////        // Check the jnlp file path argument.        if (args.length < 1) {            throw new IllegalArgumentException(                        "Please specify the jnlp file path.");        }        pkgInfo = new JnlpPackageInfo();        URL jnlp = null;        if (args[0].startsWith("http://")) {            try {                jnlp = new URL(args[0]);               } catch (MalformedURLException muE) {                throw new IOException("Invalid url argument: " +                        muE.getMessage());               }            pkgInfo.parseRemoteJnlpInfo(jnlp);        } else {            File jnlpFile = new File(args[0]);                              if (!jnlpFile.exists() || !jnlpFile.isFile()) {                throw new IOException("invalid local jnlp file: " +                        jnlpFile.getPath());               }            String resourceDir = System.getProperty(                    "JnlpConstants.PROPERTY_NAME_RESOURCEDIR");            if (resourceDir == null) {            	resourceDir = jnlpFile.getParent();            }                        pkgInfo.setResourcePath(getValidFileArgument(resourceDir,                    "resource path", false));            pkgInfo.parseLocalJnlpInfo(jnlpFile.toURL());        }        /* Set Localized information as titles, descriptions, etc. */        pkgInfo.setLocalizedInformation();                /* Check PackageName property. */        checkPackageNameArgument(pkgInfo);                /*         * Check OutputDir property.         * If the OutputDir is not set, set default outputdir as current dir.         */        checkOutputDirNameArgument(pkgInfo);                /* Check Version property. */        version = System.getProperty(JnlpConstants.PROPERTY_NAME_VERSIONNO);        if (version == null) {            version = JnlpConstants.DEFAULT_VERSION_NUM;        }        pkgInfo.setVersion(version);                /* Check Release property. */        release = System.getProperty(JnlpConstants.PROPERTY_NAME_RELEASENO);        if (release == null) {            release = JnlpConstants.DEFAULT_RELEASE_NUM;        }        pkgInfo.setRelease(release);                /*         * Check License property. If it's set, check if it points to a valid         * file.         */        licenseDirName = System.getProperty(                                JnlpConstants.PROPERTY_NAME_LICENSEDIR);        licenseDirName = getValidFileArgument(                            licenseDirName, "license directory", true);        if (licenseDirName != null) {            showLicense = true;        }        pkgInfo.setShowLicense(showLicense);        pkgInfo.setLicenseDirPath(licenseDirName);        /* Check BannerJpgFile property. */        bannerJpgFileName = System.getProperty(                            JnlpConstants.PROPERTY_NAME_BANNERJPGFILE);        bannerJpgFileName = getValidFileArgument(                              bannerJpgFileName, "Banner Jpeg File", true);        pkgInfo.setBannerJpgFilePath(bannerJpgFileName);                /* Check PanelJpgFile property. */        panelJpgFileName = System.getProperty(                        JnlpConstants.PROPERTY_NAME_PANELJPGFILE);        panelJpgFileName = getValidFileArgument(                            panelJpgFileName, "Panel Jpeg File", true);        pkgInfo.setPanelJpgFilePath(panelJpgFileName);                /* Check MSSDKPath & RawMSIFile property. */        checkMSSDKPathArgument(pkgInfo);        /* Check EnableShortcut property. */        shortcutEnabled = getBoolProperty(                        JnlpConstants.PROPERTY_NAME_ENABLESHORTCUT);        pkgInfo.setShortcutEnabled(shortcutEnabled);        /* Check EnableAssociation property. */        associationEnabled = getBoolProperty(                        JnlpConstants.PROPERTY_NAME_ENABLEASSOCIATION);        pkgInfo.setAssociationEnabled(associationEnabled);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -