You don't get to choose the Java run time on a computer. All you can do is test for what Java run time is available on someone's computer.
You have two choices for what to do in your code.
On the Nimbus page, they show you how you can test for the Nimbus look and feel, and fall back to something else if Nimbus is not available.
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
This is what Oracle recommends developers do.
Your other choice is to run a test to see what Java run time environment is available. Here's an applet from Java Tester that performs the test. The important lines are System.getProperty("java.version")
and System.getProperty("java.vendor")
.
public class JavaVersionDisplayApplet extends Applet
{ private Label m_labVersionVendor;
public JavaVersionDisplayApplet() //constructor
{ Color colFrameBackground = Color.pink;
this.setBackground(colFrameBackground);
m_labVersionVendor = new Label (" Java Version: " +
System.getProperty("java.version")+
" from "+System.getProperty("java.vendor"));
this.add(m_labVersionVendor);
}
}
Nimbus runs on Java 6 Update 10 and higher.