问题描述
当我运行此代码(请在下面找到我的代码片段)以从 jfxtras 库中获取 icalenderAgenda 时,它抛出异常
"Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.UnsupportedClassversionError: jfxtras/scene/control/agenda/Agenda has been compiled by a more recent version of the Java Runtime (class file version 54.0),this version of the Java Runtime only recognizes class file versions up to 52.0,
谁能告诉我如何解决这个问题。
注意:我的 java 运行时版本是 version 8 build 1.8.0 ,IDE=Netbeans8.2
谢谢!
import java.time.LocalDateTime;
import java.time.Period;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.borderpane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import jfxtras.labs.icalendaragenda.scene.control.agenda.ICalendaragenda;
import jfxtras.labs.icalendarfx.VCalendar;
/**
*
* @author XY
*/
public class Testicalender extends Application {
@Override
public void start(Stage primaryStage) {
borderpane root = new borderpane();
VCalendar vCalendar = new VCalendar();
ICalendaragenda agenda = new ICalendaragenda(vCalendar);
root.setCenter(agenda);
//semaine++ ou --
Button increaseweek = new Button(">>");
Button decreaseweek = new Button("<<");
HBox buttonHBox = new HBox(decreaseweek,increaseweek);
// increaseweek.setonAction((e)->
//
// { LocalDateTime newdisplayedLocalDateTime = agenda.getdisplayedLocalDateTime().plus(Period.ofWeeks(1));
// agenda.setdisplayedLocalDateTime(newdisplayedLocalDateTime);
// });
// decreaseweek.setonAction((e)->
//
// { LocalDateTime newdisplayedLocalDateTime = agenda.getdisplayedLocalDateTime().minus(Period.ofWeeks(1));
// agenda.setdisplayedLocalDateTime(newdisplayedLocalDateTime);
// });
Scene scene = new Scene(root,1366,786);
primaryStage.setScene(scene);
primaryStage.setTitle("test calendaragenda");
//primaryStage.setonCloseRequest(e-> System.out.println(vCalendar.toContent()));
primaryStage.show();
}
// /**
// * @param args the command line arguments
// */
public static void main(String[] args) {
launch(args);
}
}
解决方法
您已经下载了一个用 Java 10 编译的 jar(JFXtras 中的主要版本号表示最低 Java 版本)。
https://en.wikipedia.org/wiki/Java_class_file#General_layout
你需要 8 个。