Joe Mabel
Joe Mabel

Reputation: 1412

Can a Java applet use v1.7 or 1.8 as available without warning?

A small Java applet [Edited: that might not even be the right word: this is JNLP] in a site I support is currently compiled for Java v1.7. As v1.8 becomes increasingly common, our users are getting warnings like Firefox's "This application would like to use a version of Java (1.7) that is not installed on your system. We recommend running the application with the latest version of Java on your computer." Is there some way we could rebuild our applet to try for the 1.8 Java first and only try for the older 1.7 if 1.8 isn't available, preferably without needing to ask the user in either case? (FWIW, I'm a very experienced developer, but a rather inexperienced Java developer.)

Upvotes: 1

Views: 900

Answers (1)

Always Learning
Always Learning

Reputation: 5581

The applet can specify the version of java required using a line like this in the <resources> section of the code:

<j2se version="1.7*">

The version number specified can either end with a number, and asterisk or a plus sign.

  • 1.7 would mean the version must be 1.7.
  • 1.7* means anything at or higher than 1.7 but less than 1.8 (like 1.7.1).
  • 1.7+ means anything 1.7 or higher (including 1.8).

If your code should run fine on Java 7 or Java 8, then you'd want "1.7+" to indicate you're not that picky about it.

Upvotes: 1

Related Questions