- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在学习完一组类(class)/教程后,我尝试在 JavaFX 中创建图书馆管理系统,但遇到了以下问题:java.lang.RuntimeException:应用程序启动方法中出现异常 & java.lang.NullPointerException:需要位置。
我已经检查了很多关于这两个特定问题的主题,但似乎没有任何帮助。我正在使用 SceneBuilder 9.0.1/Java 8.0/NetBeans 8.2。
请记住:我是 java/javaFX 的菜鸟,我正在尝试在学习这些主题的同时完成作业。非常感谢您的帮助。
代码如下:
package bibliotecajfx.ui.adaugacarte;
import bibliotecajfx.*;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
*
* @author Munteanu Mihail
*/
public class BibliotecaJFX extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
还有 FXMLController 的副本:
package bibliotecajfx.ui.adaugacarte;
import bibliotecajfx.*;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTextField;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
/**
*
* @author Munteanu Mihail
*/
public class FXMLDocumentController implements Initializable {
private Label label;
@FXML
private JFXTextField title;
@FXML
private JFXTextField id;
@FXML
private JFXTextField editura;
@FXML
private JFXTextField autor;
@FXML
private JFXButton saveButton;
@FXML
private JFXButton cancelButton;
DatabaseHandler databaseHandler;
@Override
public void initialize(URL url, ResourceBundle rb) {
databaseHandler = new DatabaseHandler();
}
@FXML
private void addBook(ActionEvent event) {
}
@FXML
private void cancel(ActionEvent event) {
}
}
数据库代码:
package bibliotecajfx.database;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
//import jdk.nashorn.internal.ir.Statement;
/**
*
* @author Munteanu Mihail
*/
public class DatabaseHandler {
private static DatabaseHandler handler;
private static final String DB_URL = "jdbc:derby:database;create:true";
private static Connection conn = null;
private static Statement stat = null;
public DatabaseHandler(){
createConnection();
setupBookTable();
}
void createConnection(){
try{
Class.forName("org.apache.derby.jdbc.EnableDriver").newInstance();
conn = DriverManager.getConnection(DB_URL);
}catch(Exception e){
e.printStackTrace();
}
}
void setupBookTable(){
String TABLE_NAME= "CARTE";
try{
stat = conn.createStatement();
DatabaseMetaData dbm = conn.getMetaData();
ResultSet tables = dbm.getTables(null, null, TABLE_NAME.toUpperCase(), null);
if(tables.next()){
System.out.println("Tabela"+TABLE_NAME+"exista deja!");
}else{
stat.execute("TABELA CREATA "+TABLE_NAME+"("
+" id varchar(200) primary key, \n"
+" titlu varchar(200), \n"
+" autor varchar(200),\n"
+" editura varchar(100),\n"
// +" intcode varchar(100),\n"
+" isAvail boolean defaul true"
+" )");
}
}catch(SQLException e){
System.err.println(e.getMessage()+" === init Database");
}finally{
}
}
}
和日志:
ant -f "C:\\Users\\Munteanu Mihail\\Desktop\\bibliotecaJFX" -Djavafx.main.class=bibliotecajfx.ui.adaugacarte.BibliotecaJFX jfxsa-run
init:
deps-clean:
Updating property file: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\built-clean.properties
Deleting directory C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build
clean:
init:
deps-jar:
Created dir: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build
Updating property file: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\built-jar.properties
Created dir: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\classes
Created dir: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\empty
Created dir: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\generated-sources\ap-source-output
Compiling 4 source files to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\classes
warning: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\jfoenix-9.0.0.jar(com/jfoenix/controls/JFXButton.class): major version 53 is newer than 52, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\jfoenix-9.0.0.jar(com/jfoenix/controls/JFXTextField.class): major version 53 is newer than 52, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
2 warnings
Copying 2 files to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\classes
compile:
Created dir: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist
Copying 3 files to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\lib
Detected JavaFX Ant API version 1.3
Going to create default keystore in C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\nb-jfx.jks
Generating Key for nb-jfx
Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\nb-jfx.jks -destkeystore C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\build\nb-jfx.jks -deststoretype pkcs12".
Launching <fx:jar> task from C:\Program Files\Java\jdk1.8.0_152\jre\..\lib\ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Signing JAR: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\bibliotecaJFX.jar to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\bibliotecaJFX.jar as nb-jfx
jar signed.
Warning:
The signer certificate will expire within six months.
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2018-04-12) or after any future revocation date.
Enter Passphrase for keystore: Enter key password for nb-jfx:
Signing JAR: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\lib\derby.jar to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\lib\derby.jar as nb-jfx
jar signed.
Warning:
The signer certificate will expire within six months.
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2018-04-12) or after any future revocation date.
Enter Passphrase for keystore: Enter key password for nb-jfx:
Signing JAR: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\lib\derbyclient.jar to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\lib\derbyclient.jar as nb-jfx
jar signed.
Warning:
The signer certificate will expire within six months.
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2018-04-12) or after any future revocation date.
Enter Passphrase for keystore: Enter key password for nb-jfx:
Signing JAR: C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\lib\jfoenix-9.0.0.jar to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\lib\jfoenix-9.0.0.jar as nb-jfx
jar signed.
Warning:
The signer certificate will expire within six months.
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2018-04-12) or after any future revocation date.
Enter Passphrase for keystore: Enter key password for nb-jfx:
Launching <fx:deploy> task from C:\Program Files\Java\jdk1.8.0_152\jre\..\lib\ant-javafx.jar
No base JDK. Package will use system JRE.
No base JDK. Package will use system JRE.
jfx-deployment-script:
jfx-deployment:
jar:
Copying 15 files to C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\run1897499086
jfx-project-run:
Executing C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\run1897499086\bibliotecaJFX.jar using platform C:\Program Files\Java\jdk1.8.0_152\jre/bin/java
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsupportedClassVersionError: com/jfoenix/controls/JFXButton 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
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at bibliotecajfx.ui.adaugacarte.BibliotecaJFX.start(BibliotecaJFX.java:23)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Exception running application bibliotecajfx.ui.adaugacarte.BibliotecaJFX
Java Result: 1
Deleting directory C:\Users\Munteanu Mihail\Desktop\bibliotecaJFX\dist\run1897499086
jfxsa-run:
BUILD SUCCESSFUL (total time: 20 seconds)
项目布局:
最佳答案
首先我要说的是,您的 FXML 文件的路径是错误的。根据你的项目布局,应该是
Parent root = FXMLLoader.load(getClass().getResource("/bibliotecajfx/ui/adaugacarte/FXMLDocument.fxml"));
因为那是你的java包树。开头的 /
表示该路径是从 jar 文件根目录开始的绝对路径。
此外,您正在使用的 JFoenix 库已使用较新版本的 Java 进行编译,因此您应该更新您的库。或者至少确保 JFoenix 的版本和您的 Java 版本相同。
干杯
关于应用程序启动方法/位置中的 JavaFX 异常需要修复,无需修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48175133/
我正在制作简单播放本地视频的应用程序。 一开始我用https://pub.dev/packages/video_player , video_player: ^0.10.2+1 但是由于某种原因,它在
基本上,我有一个 boolean 值,大型 API 项目中大约 20% 的类都使用它。从实用方法到更大的类,一切都使用它。我可以在程序启动时设置状态(不会改变),但不知道访问它的“最佳”方式。 最初,
我正在处理一些广告数据,例如电子邮件数据。我有两个数据集: 邮件级别,针对每个人,说明他们的邮寄日期,以及他们的转换日期。 import pandas as pd df_emailed=pd.Data
例如,我在 A 列中输入了数据,在 B 列中输入了一些复杂的公式作为 A 中数据的函数。A 中的数据行数取决于用户输入。它可以在 2 到 100,000 之间。传统上,我将使用相同的公式填充 B 列的
我正在寻找一种简单的时钟同步协议(protocol),该协议(protocol)易于实现且占用空间小,并且在没有互联网连接的情况下也可以工作,因此可以用于例如在封闭的实验室网络中。需要明确的是,我不是
这是 Objective-J/Cappuccino 的问题,但我添加了 cocoa 标签,因为框架非常相似。 Cappuccino 的缺点之一是 CoreData 尚未移植,因此您必须手动创建所有模型
例如,如果您按退格键,控制台会显示 keyVal 的空字符串,但这会产生误导,因为 keyVal.length 等于 1 还有一个隐藏字符 element.on('keydown',function(
我已经下载了一个主题,我想安装它。现在我位于“外观”>“主题”>“添加”>“新建/上传主题”。WordPress 需要 FTP 访问。好吧,我在本地计算机上,没有 FTP 服务器正在监听端口 21。
所以我认为我疯了,也许我疯了,但这看起来很简单。假设我有这段代码: let a = {}; a.b.c.d.e.f.g = 'Something Awesome'; 现在您可以想象如果检查噩梦就必须进
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
这个问题已经有答案了: How set item checkbox when i click on element span which have this checkbox? (3 个回答) 已关闭
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我已经为下拉菜单编写了一个自定义指令。这些元素绝对定位在相对定位的父元素内,因此我需要获取下拉触发元素的高度,以便将实际菜单移动到其下方。触发器是指令元素的子元素。我想避免使用成熟的 jQuery,而
我需要向端点提交表单,但由于我无法控制 CORS header ,因此无法使用 AJAX 执行此操作。 我目前正在通过渲染隐藏的 iframe 并将提交作为目标来执行此操作。但我仍然无法捕获该事件(我
我的 JSON 输入: { "Key": "Team", "Value": "AA" } { "Key": "Division", "Value": "BB" } 期望的输出: [
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
Pair: BUX/TIX Spread: 113 Rate: 10.159/10.272 High/Low: 115 我想获取值 113 和值 115,但
我正在尝试了解 IPB 论坛的运作方式。 如果我勾选记住我,那么即使我关闭浏览器并重新打开它,我也会保持登录状态。 我正在尝试弄清楚这是如何实现的,因为服务器设置的唯一 cookie 在 sessio
我一直在阅读有关 VIM 的 youcompleteme 插件的内容。然而,问题是我想要一个可以转移到其他开发平台(OpenIndiana、FreeBSD、Linux 和 OS X)上的设置。 使用
我需要找到 Excel 电子表格中的最后一个非空单元格,但我需要它的地址,而不是它的值。 例如:当我想要 K 列中最后一个非空单元格的值时,我使用以下公式: =LOOKUP(2;1/(NOT(ISBL
我是一名优秀的程序员,十分优秀!