java - NullPointerException loading fxml file from javafx applet -


i'm trying create javafx applet, using intellij idea. after building 3 files: .jar, .jnlp , .html. if launch jar works fine, if try run app using jnlp or html throws exception:

java.lang.nullpointerexception: location required.     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.load(unknown source)     @ sample.main.start(main.java:14)     @ com.sun.javafx.applet.fxapplet2$2.run(unknown source)     @ com.sun.javafx.application.platformimpl.lambda$null$170(unknown source)     @ com.sun.javafx.application.platformimpl$$lambda$45/31918841.run(unknown source)     @ java.security.accesscontroller.doprivileged(native method)     @ com.sun.javafx.application.platformimpl.lambda$runlater$171(unknown source)     @ com.sun.javafx.application.platformimpl$$lambda$44/13936151.run(unknown source)     @ com.sun.glass.ui.invokelaterdispatcher$future.run(unknown source)     @ com.sun.glass.ui.win.winapplication._runloop(native method)     @ com.sun.glass.ui.win.winapplication.lambda$null$145(unknown source)     @ com.sun.glass.ui.win.winapplication$$lambda$34/10055096.run(unknown source)     @ java.lang.thread.run(unknown source) exception in thread "javafx application thread" java.lang.runtimeexception: java.lang.nullpointerexception: location required.     @ com.sun.javafx.applet.fxapplet2$2.run(unknown source)     @ com.sun.javafx.application.platformimpl.lambda$null$170(unknown source)     @ com.sun.javafx.application.platformimpl$$lambda$45/31918841.run(unknown source)     @ java.security.accesscontroller.doprivileged(native method)     @ com.sun.javafx.application.platformimpl.lambda$runlater$171(unknown source)     @ com.sun.javafx.application.platformimpl$$lambda$44/13936151.run(unknown source)     @ com.sun.glass.ui.invokelaterdispatcher$future.run(unknown source)     @ com.sun.glass.ui.win.winapplication._runloop(native method)     @ com.sun.glass.ui.win.winapplication.lambda$null$145(unknown source)     @ com.sun.glass.ui.win.winapplication$$lambda$34/10055096.run(unknown source)     @ java.lang.thread.run(unknown source) caused by: java.lang.nullpointerexception: location required.     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.loadimpl(unknown source)     @ javafx.fxml.fxmlloader.load(unknown source)     @ sample.main.start(main.java:14)     ... 11 more 

why so? jar contains needed fxml located @ specified path.

java:

package sample;  import javafx.application.application; import javafx.fxml.fxmlloader; import javafx.scene.parent; import javafx.scene.scene; import javafx.stage.stage;  public class main extends application {     @override     public void start(stage primarystage) throws exception{         parent root = fxmlloader.load(getclass().getresource("/sample/sample.fxml"));         primarystage.settitle("hello world");         primarystage.setscene(new scene(root, 600, 400));         primarystage.show();     }      public static void main(string[] args) {         launch(args);     } } 

fxml:

<?xml version="1.0" encoding="utf-8"?>  <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?>  <anchorpane prefheight="400.0" prefwidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">    <children>       <button layoutx="173.0" layouty="188.0" prefheight="25.0" prefwidth="255.0" text="button" />    </children> </anchorpane> 

what doing wrong? please.

the problem in line:

parent root = fxmlloader.load(getclass().getresource("/sample/sample.fxml")); 

it pretty clear load method being called null argument. , happens because getresource("/sample/sample.fxml") cannot file resource.

the resource missing (or has wrong path) on runtime classpath.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -