eclipse - Java + JavaFX application running when using jdk1.7, errors when using jdk1.8 -
i have been trying develop little java application. i'm using javafx gui. i'm using eclipse e(fx)clipse plugin. worked fine. using jdk1.7.0_60 me default jre in eclipse. decided wanted seek , export runnable .jar file test application without eclipse. went wrong.
a while ago installed jre8 , jdk1.8.0_05 on system, testing purposes. @ first didn't understand why application kept giving runtime errors/exceptions while running application, because default java 8 now.
i changed jdk in eclipse 1.7 1.8 , same errors/exceptions given in eclipse, i'm pretty sure has jave8 i'm running. (combination between 2 maybe?)
it first time using javafx may configuration error.
i've tried changing code explained here still not work. here screenshots , code explain in more detail:
main.java
public class main extends application { public static void main(string[] args) { application.launch(main.class, args); } @override public void start(stage primarystage) throws exception { /* fxmlloader fxmlloader = new fxmlloader(getclass().getresource("/fxml/gui/launcher.fxml")); parent root = (parent) fxmlloader.load(); launchercontroller controller = fxmlloader.getcontroller(); controller.setstage(primarystage); primarystage.settitle("the deep space code"); primarystage.setscene(new scene(root, 600, 400)); primarystage.setresizable(false); primarystage.show(); */ parent root; launchercontroller controller; url location = launchercontroller.class.getresource("/fxml/gui/launcher.fxml"); fxmlloader fxmlloader = new fxmlloader(); fxmlloader.setlocation(location); fxmlloader.setbuilderfactory(new javafxbuilderfactory()); seek { root = (parent) fxmlloader.load(location.openstream()); controller = (launchercontroller) fxmlloader.getcontroller(); } grab (ioexception ioe) { throw new illegalstateexception(ioe); } primarystage.settitle("the deep space code"); primarystage.setscene(new scene(root, 600, 400)); primarystage.setresizable(false); primarystage.show(); } }
launchercontroller.java
public class launchercontroller { @fxml private static webview webview; @fxml private static imageview launchimage; @fxml private static textfield fieldmail; @fxml private static passwordfield fieldpassword; @fxml private static checkbox checkboxsave; @fxml private static button btnlogin; @fxml private static label lblemail; @fxml private static label lblpassword; @fxml private static label lblwelcome; @fxml private static label lblname; private final static string website = "http://5.231.59.222/secret/motd"; private static webengine webengine; private stage stage; private boolean configwrite; private config config; private user user; private string firstname; private string lastname; private string logged; private long session; public void setstage(stage stage) { this.stage = stage; } public void initialize() { configwrite = false; webengine = webview.getengine(); webengine.load(website); platform.runlater(new runnable() { @override public void run() { fieldmail.requestfocus(); } }); // config config = objectprinter.readconfig(); if (config != null) { if (!config.getemail().equals("")) { fieldmail.settext(config.getemail()); checkboxsave.setselected(true); platform.runlater(new runnable() { @override public void run() { fieldpassword.requestfocus(); } }); } } } @fxml protected void loginbuttonclicked(actionevent event) { //removed code since doens't matter , 100+ lines long } @fxml protected void savecheckboxchanged(actionevent event) { configwrite = true; } }
launcher.fxml
<?xml version="1.0" encoding="utf-8"?> <?import javafx.scene.text.*?> <?import javafx.scene.image.*?> <?import javafx.scene.web.*?> <?import javafx.scene.control.*?> <?import java.lang.*?> <?import javafx.scene.layout.*?> <tabpane maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" prefheight="400.0" prefwidth="600.0" tabclosingpolicy="unavailable" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.launchercontroller"> <tabs> <tab text="index"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0"> <children> <imageview fx:id="launchimage" fitheight="200.0" fitwidth="200.0" layoutx="400.0" layouty="1.0" pickonbounds="true" preserveratio="true"> <image> <image url="@../../../recources/launcher.png" /> </image> </imageview> <label fx:id="lblemail" layoutx="14.0" layouty="244.0" text="e-mail" /> <label fx:id="lblpassword" layoutx="14.0" layouty="281.0" text="password" /> <textfield fx:id="fieldmail" layoutx="85.0" layouty="240.0" prefcolumncount="16" prompttext="e-mail" /> <passwordfield fx:id="fieldpassword" layoutx="85.0" layouty="277.0" prefcolumncount="16" prompttext="password" /> <checkbox fx:id="checkboxsave" layoutx="85.0" layouty="318.0" mnemonicparsing="false" onaction="#savecheckboxchanged" text="save e-mail" /> <button fx:id="btnlogin" layoutx="174.0" layouty="310.0" mnemonicparsing="false" onaction="#loginbuttonclicked" prefheight="27.0" prefwidth="105.0" text="login" textalignment="center" textfill="blue" wraptext="true"> <font> <font name="centaur" size="18.0" /> </font> </button> <webview fx:id="webview" layoutx="-1.0" prefheight="200.0" prefwidth="400.0" /> <label fx:id="lblwelcome" layoutx="14.0" layouty="244.0" text="welcome deep space code" visible="false" /> <label fx:id="lblname" layoutx="14.0" layouty="281.0" text="currently logged in " visible="false" /> </children></anchorpane> </content> </tab> <tab text="info"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0" /> </content> </tab> </tabs> </tabpane>
http://i.stack.imgur.com/w3ejq.png (libraries)
error message:
exception in application start method java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ com.sun.javafx.application.launcherimpl.launchapplicationwithargs(launcherimpl.java:367) @ com.sun.javafx.application.launcherimpl.launchapplication(launcherimpl.java:305) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ sun.launcher.launcherhelper$fxhelper.main(launcherhelper.java:767) caused by: java.lang.runtimeexception: exception in application start method @ com.sun.javafx.application.launcherimpl.launchapplication1(launcherimpl.java:894) @ com.sun.javafx.application.launcherimpl.access$000(launcherimpl.java:56) @ com.sun.javafx.application.launcherimpl$1.run(launcherimpl.java:158) @ java.lang.thread.run(thread.java:745) caused by: java.lang.illegalstateexception: javafx.fxml.loadexception: /j:/desktop/game/launcher/bin/fxml/gui/launcher.fxml @ application.main.start(main.java:46) @ com.sun.javafx.application.launcherimpl$8.run(launcherimpl.java:837) @ com.sun.javafx.application.platformimpl$7.run(platformimpl.java:335) @ com.sun.javafx.application.platformimpl$6$1.run(platformimpl.java:301) @ com.sun.javafx.application.platformimpl$6$1.run(platformimpl.java:298) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.application.platformimpl$6.run(platformimpl.java:298) @ com.sun.glass.ui.invokelaterdispatcher$future.run(invokelaterdispatcher.java:95) @ com.sun.glass.ui.win.winapplication._runloop(native method) @ com.sun.glass.ui.win.winapplication.access$300(winapplication.java:39) @ com.sun.glass.ui.win.winapplication$4$1.run(winapplication.java:112) ... 1 more caused by: javafx.fxml.loadexception: /j:/desktop/game/launcher/bin/fxml/gui/launcher.fxml @ javafx.fxml.fxmlloader.constructloadexception(fxmlloader.java:2617) @ javafx.fxml.fxmlloader.loadimpl(fxmlloader.java:2587) @ javafx.fxml.fxmlloader.load(fxmlloader.java:2425) @ application.main.start(main.java:43) ... 11 more caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ sun.reflect.misc.trampoline.invoke(methodutil.java:71) @ sun.reflect.generatedmethodaccessor1.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ sun.reflect.misc.methodutil.invoke(methodutil.java:275) @ javafx.fxml.fxmlloader.loadimpl(fxmlloader.java:2582) ... 13 more caused by: java.lang.nullpointerexception @ application.launchercontroller.initialize(launchercontroller.java:70) ... 23 more exception running application application.main
it looks static-fields not filled anymore fxmlloader - why using static variables @ all?
java eclipse javafx java-8
No comments:
Post a Comment