Reputation: 41
My custom class:
public class IntegerField extends TextField {
public IntegerField() {
super();
restrictToNumbersOnly();
}
public IntegerField(String text) {
super(text);
restrictToNumbersOnly();
}
public void restrictToNumbersOnly() {
// Irrelevant
}
}
I then try to add this custom class like this:
<IntegerField fx:id="example" />
IntelliJ's Scene Builder outputs this error:
java.lang.UnsupportedClassVersionError: path/IntegerField has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I've tried searching for this error but haven't found anything that explains why this shouldn't work. The examples I've found have indicated that it should be possible to just extend from the control class, and import it directly into the fxml file, and it does. It works perfectly when running the program, it's scene builder that is the issue.
I realize that this is a Java version issue, but the whole project is set to Java 9 (53) and I've experimented with changing the versions to no avail.
Upvotes: 1
Views: 695
Reputation: 41
I have not found a fix for the in-built Scene Builder, but I have found a workaround on an external Scene Builder, using these steps:
Upvotes: 1
Reputation: 312267
You've compiled your class with Java 9's target level (thus generating a class version of 53), but you're trying to run it with Java 8.
Either run it with Java 9, or build it with a target language level of 8.
Upvotes: 0