Ignore:
Timestamp:
2017-05-20T19:06:29+02:00 (7 years ago)
Author:
Don-vip
Message:

see #14652 - ask Windows/macOS users to update their version of Java when it expires (i.e when the built-in JRE expiration date is passed, about 4 months after release, 1 month after Java should have asked to update by itself). It currently proposes to update all versions of Java 8 up to update 121, released on January 17, 2017, as its expiration date is May 18, 2017.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r12217 r12219  
    3232import java.security.PrivilegedAction;
    3333import java.text.Bidi;
     34import java.text.DateFormat;
    3435import java.text.MessageFormat;
     36import java.text.ParseException;
    3537import java.util.AbstractCollection;
    3638import java.util.AbstractList;
     
    3941import java.util.Collection;
    4042import java.util.Collections;
     43import java.util.Date;
    4144import java.util.Iterator;
    4245import java.util.List;
     
    16461649        return Integer.parseInt(version.substring(bPos > -1 ? bPos + 1 : pPos + 1, version.length()));
    16471650    }
     1651
     1652    /**
     1653     * Returns the JRE expiration date.
     1654     * @return the JRE expiration date, or null
     1655     * @since 12219
     1656     */
     1657    public static Date getJavaExpirationDate() {
     1658        try {
     1659            Object value = Class.forName("com.sun.deploy.config.BuiltInProperties").getDeclaredField("JRE_EXPIRATION_DATE").get(null);
     1660            if (value instanceof String) {
     1661                return DateFormat.getDateInstance(3, Locale.US).parse((String) value);
     1662            }
     1663        } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException | ParseException e) {
     1664            Main.debug(e);
     1665        }
     1666        return null;
     1667    }
     1668
     1669    /**
     1670     * Returns the latest version of Java, from Oracle website.
     1671     * @return the latest version of Java, from Oracle website
     1672     * @since 12219
     1673     */
     1674    public static String getJavaLatestVersion() {
     1675        try {
     1676            return HttpClient.create(
     1677                    new URL(Main.pref.get("java.baseline.version.url", "http://javadl-esd-secure.oracle.com/update/baseline.version")))
     1678                    .connect().fetchContent().split("\n")[0];
     1679        } catch (IOException e) {
     1680            Main.error(e);
     1681        }
     1682        return null;
     1683    }
    16481684}
Note: See TracChangeset for help on using the changeset viewer.