Example usage for org.apache.commons.lang SystemUtils JAVA_VERSION_FLOAT

List of usage examples for org.apache.commons.lang SystemUtils JAVA_VERSION_FLOAT

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils JAVA_VERSION_FLOAT.

Prototype

float JAVA_VERSION_FLOAT

To view the source code for org.apache.commons.lang SystemUtils JAVA_VERSION_FLOAT.

Click Source Link

Document

Gets the Java version as a float.

Example return values:

  • 1.2f for JDK 1.2
  • 1.31f for JDK 1.3.1

The field will return zero if #JAVA_VERSION is null.

Usage

From source file:org.codehaus.mojo.webstart.JnlpMojo.java

private void checkInput() throws MojoExecutionException {

    getLog().debug("a fact " + this.artifactFactory);
    getLog().debug("a resol " + this.artifactResolver);
    getLog().debug("basedir " + this.basedir);
    getLog().debug("gzip " + this.gzip);
    getLog().debug("pack200 " + this.pack200);
    getLog().debug("project " + this.getProject());
    getLog().debug("zipArchiver " + this.zipArchiver);
    // getLog().debug( "usejnlpservlet " + this.usejnlpservlet );
    getLog().debug("verifyjar " + this.verifyjar);
    getLog().debug("verbose " + this.verbose);

    if (jnlp == null) {
        // throw new MojoExecutionException( "<jnlp> configuration element missing." );
    }//w ww .  j  a v  a  2  s  .com

    if (SystemUtils.JAVA_VERSION_FLOAT < 1.5f) {
        if (pack200) {
            throw new MojoExecutionException("SDK 5.0 minimum when using pack200.");
        }
    }

    // FIXME
    /*
    if ( !"pom".equals( getProject().getPackaging() ) ) {
    throw new MojoExecutionException( "'" + getProject().getPackaging() + "' packaging unsupported. Use 'pom'" );
    }
    */
}

From source file:org.eclipse.wb.internal.swing.model.bean.AbstractActionInfo.java

private List<Property> createProperties() throws Exception {
    CreationSupport creationSupport = getCreationSupport();
    // no additional properties available
    if (!(creationSupport instanceof IActionSupport)) {
        return Lists.newArrayList();
    }//from   w ww  .ja v a 2 s. c  o  m
    // create properties
    List<Property> properties = Lists.newArrayList();
    properties.add(createStringProperty("name", "NAME"));
    properties.add(createStringProperty("short description", "SHORT_DESCRIPTION"));
    properties.add(createStringProperty("long description", "LONG_DESCRIPTION"));
    properties.add(createIconProperty("small icon", "SMALL_ICON"));
    properties.add(createStringProperty("action command", "ACTION_COMMAND_KEY"));
    properties.add(createProperty("accelerator", "ACCELERATOR_KEY", null, KeyStrokePropertyEditor.INSTANCE));
    properties
            .add(createProperty("mnemonic", "MNEMONIC_KEY", null, DisplayedMnemonicKeyPropertyEditor.INSTANCE));
    if (SystemUtils.JAVA_VERSION_FLOAT >= 1.6) {
        properties.add(createProperty("displayed mnemonic index", "DISPLAYED_MNEMONIC_INDEX_KEY",
                IntegerConverter.INSTANCE, IntegerPropertyEditor.INSTANCE));
        properties.add(createIconProperty("large icon", "LARGE_ICON_KEY"));
    }
    // remove null-s
    Iterables.removeIf(properties, Predicates.isNull());
    return properties;
}

From source file:org.eclipse.wb.tests.designer.core.util.reflect.ReflectionUtilsTest.java

/**
 * Test for {@link ReflectionUtils#getPropertyDescriptors(BeanInfo, Class)}.
 * <p>//from   www  .ja  v a 2 s . c o  m
 * When we try to use "bridge" method during {@link PropertyDescriptor} creation, this causes
 * exception under OpenJDK 6 and 7.
 */
public void test_getPropertyDescriptors_whenBridgeMethod() throws Exception {
    @SuppressWarnings({ "unused" })
    class GenericClass<T> {
        public T getFoo() {
            return null;
        }

        public void setFoo(T value) {
        }
    }
    class SpecificClass extends GenericClass<String> {
        @Override
        public String getFoo() {
            return null;
        }
    }
    // prepare PropertyDescriptor-s
    Map<String, PropertyDescriptor> descriptors = getPropertyDescriptorNames(SpecificClass.class);
    // check "foo(java.lang.Object)"
    PropertyDescriptor propertyDescriptor;
    if (SystemUtils.JAVA_VERSION_FLOAT < 1.7f) {
        propertyDescriptor = descriptors.get("foo(java.lang.Object)");
    } else {
        propertyDescriptor = descriptors.get("foo");
    }
    assertNotNull(propertyDescriptor);
    assertSame(Object.class, propertyDescriptor.getPropertyType());
}

From source file:org.n0pe.mojo.asadmin.AbstractAsadminMojo.java

private void checkConfig() throws MojoExecutionException, MojoFailureException {
    if (StringUtils.isEmpty(glassfishHome) || "ENV".equals(glassfishHome)) {
        if (SystemUtils.JAVA_VERSION_FLOAT < 1.5) {
            throw new MojoExecutionException(
                    "Neither GLASSFISH_HOME, AS_HOME nor the glassfishHome configuration parameter is set! "
                            + "Also, to save you the trouble, environment cannot be read running maven with a VM < 1.5, "
                            + "so set the glassFishHome configuration parameter or use -D.");
        }//w  ww  .  ja va  2  s  .co  m
        glassfishHome = System.getenv("GLASSFISH_HOME");
        if (StringUtils.isEmpty(glassfishHome)) {
            glassfishHome = System.getenv("AS_HOME");
        }
    }
    if (StringUtils.isEmpty(glassfishHome)) {
        throw new MojoExecutionException(
                "Neither GLASSFISH_HOME, AS_HOME nor the glassfishHome configuration parameter is set!");
    }
    glassfishHomeDir = new File(glassfishHome);
    if (!glassfishHomeDir.exists()) {
        throw new MojoFailureException("The specifed glassfishHome does not exist.");
    }
    if (StringUtils.isEmpty(passwordfile) || "HOME".equals(passwordfile)) {
        passwordfile = null;
        if (new File(System.getenv("HOME") + File.separator + ".asadminpass").exists()) {
            passwordfile = System.getenv("HOME") + File.separator + ".asadminpass";
        } else if (new File(System.getenv("HOME") + File.separator + ".asadmintruststore").exists()) {
            passwordfile = System.getenv("HOME") + File.separator + ".asadmintruststore";
        }
    } else if (!new File(passwordfile).exists()) {
        passwordfile = null;
    }
    if (StringUtils.isEmpty(passwordfile)) {
        throw new MojoFailureException(
                "Given password file does not exists or cannot find an existing asadmin password file");
    }
}