NullPointerException loading fxml file from javafx applet - java

I'm trying to create javafx applet, using IntelliJ Idea. After building I get three files: .jar, .jnlp and .html. If I launch jar all works fine, but if I try to run app using jnlp or html it throws exception:
java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at sample.Main.start(Main.java:14)
at com.sun.javafx.applet.FXApplet2$2.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/31918841.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$44/13936151.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$34/10055096.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.NullPointerException: Location is required.
at com.sun.javafx.applet.FXApplet2$2.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/31918841.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$44/13936151.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$34/10055096.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at sample.Main.start(Main.java:14)
... 11 more
Why is it so? Jar exactly contains needed fxml located at the 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 am I doing wrong? Help please.

The problem is in this line:
Parent root = FXMLLoader.load(getClass().getResource("/sample/sample.fxml"));
It is pretty clear that the load method is actually being called with a null argument. And that happens because getResource("/sample/sample.fxml") cannot file that resource.
The resource is missing (or has the wrong path) on the runtime classpath.

This is a problem of security. The FXML file is considered as to be loaded from the filesystem of the client, but the "user.dir, read" permission is not tolerated by the Java security manager.
However, it is a problem of signing JavaFX applets. Once signed, the loading works well. Example here: http://web.univ-pau.fr/~barbier/PauWare/My_device/dist/My_device_JavaFX.html
BTW, there is no problem with JavaFX applications
(eg, http://www.franckbarbier.com/PauWare/Programmable_thermostat/) that have self-contained widgets in the code (no load of FXML file). Cheers!!

Related

Eclipse - JavaFX FXML LoadException

I'm very, VERY new to using JavaFX and FXML in general, and I've run into a bit of a problem that I've not been able to solve either through repeated Google searches, or searches here on Stack Exchange. While others have had similar problems, I haven't been able to replicate their solutions within my own project.
Right now, I'm mostly just trying to test JavaFX with FXML and get a feel for it... however I can't even get it to load, as FXMLLoader is giving me the following error.
javafx.fxml.LoadException:
/C:/Users/Dylon/workspace/Convergence_titanExplorationModule/bin/com/test/fxml/ExplorationModuleUI.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source) at
javafx.fxml.FXMLLoader.importClass(Unknown Source) at
javafx.fxml.FXMLLoader.processImport(Unknown Source) at
javafx.fxml.FXMLLoader.processProcessingInstruction(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at
javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at
javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at
javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at
javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at
javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at
javafx.fxml.FXMLLoader.loadImpl(Unknown Source) at
javafx.fxml.FXMLLoader.load(Unknown Source) at
com.test.fxml.Main.start(Main.java:14) at
com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(Unknown
Source) at
com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(Unknown
Source) at
com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown
Source) at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown
Source) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown
Source) at com.sun.glass.ui.win.WinApplication._runLoop(Native
Method) at
com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source)
at java.lang.Thread.run(Unknown Source) Caused by:
java.lang.ClassNotFoundException at
javafx.fxml.FXMLLoader.loadType(Unknown Source) ... 21 more
Now, here's the code I'm working with...
package com.test.fxml;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("/com/test/fxml/ExplorationModuleUI.fxml"));
Scene scene = new Scene(root,400,400);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
Here's my FXML file, named ExplorationModuleUI.fxml...
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control*?>
<BorderPane xmlns:fx="http://javafx.com/fxml/1">
<TOP>
<HBox>
<Button text = "test"/>
</HBox>
</TOP>
</BorderPane>
Finally, here's how I have things laid out in regards to folders.
I can't post images yet so here's a link to one instead
Any help is greatly appreciated. I honestly haven't been able to figure out why it doesn't work even after digging about for a couple of hours tonight. I've tried other solutions I've found on here and in Google searches, but nothing has worked yet. If you have any questions feel free to ask and I'll get back to you as soon as I can in the morning.
First, your second import is missing a dot between control and *, it should be import javafx.scene.control.*
Second, TOP is not a valid element for fxml, use top instead (all lowercase).

FXML - Jar to .exe fail

I found several similar problems, but nowhere I found true and working solution for this problem, so I ask the world if somebody solved it this JavaFX problem?
I tried to make .exe from my JavaFX project (.jar file) with several converter softwares, but I get this error message from all (below) What could cause this, if the .jar file is working if I open it?
(My file hierarchy is something like this:)
-/lib/derby.jar (set as Native)
-/lib/derbyclient.jar (set as Native)
-/lib/derbynet.jar (set as Native)
-/lib/itextpdf-5.5.5.jar (set as Native)
-/lib/jfxtras-labs-samples-8.0-r4-SNAPSHOT-shadow.jar (set as Native)
-Utiokos.jar(with the main class) (set as Main)
The error message I get from the start of the .exe after converting:
java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$1/15539988.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/MrFireman/AppData/Local/Temp/e4jB580.tmp_dir1427146294/Utiokos.jar!/Utiokos/Foablak.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at Utiokos.Utiokos.start(Utiokos.java:27)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/20813951.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/2077920.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/29246076.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/17481965.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$38/28810240.run(Unknown Source)
... 1 more
Caused by: java.lang.NullPointerException
at Utiokos.AdatbazisKapcsolat.aktivNev(AdatbazisKapcsolat.java:228)
at Utiokos.FoablakController.initialize(FoablakController.java:2547)
... 23 more
The solution was to not just add the /lib/xy.jar as a Native, but also as a classpath!
That way everything is working properly in the .exe! ;)

Why is the Desktop API throw a NPE when app is ran as Java Web Start?

I have only be working with Java for about 6 months, so I definitely a newbie. Also, I did post this question on the Oracle Technical Network Community a few days ago, but have heard nothing.
The application I have been developing is being beta tested currently via web start. We thought this was the best way to keep users up to date with the latest bug fixes. I guess I should mention it is a JavaFX app that uses Maven. In the application, I'm using the OPEN and MAIL actions of the Desktop API. The OPEN action is being used to open the system folder browser. This is the action I need to get working. The MAIL action is more for user convenience. Both work fine when running the application from the executable jar, but I get a NPE for both when the app is launched through web start. It passes the isDesktopSupported test. Everything is signed with a verified DigiCert certificate and has all-permissions set. When the app first launchs it creates a folder and config file in the user home directory with no problem.
I created a small demo app to make sure there wasn't something elsewhere in my app causing the problem, but I get the exact same error. The code I'm posting is from the demo app.
FXMLController.java
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
public class FXMLController implements Initializable {
#FXML
private Button button;
#FXML
private Hyperlink hyperlink;
#FXML
private void handleButtonAction(ActionEvent event) {
if (Desktop.isDesktopSupported()) {
if (Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) { //NPE thrown here
try {
Desktop.getDesktop().open(new File(System.getProperty("user.home")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
System.out.println("The OPEN action is not supported on your current platform.");
}
} else {
System.out.println("The Desktop class is not supported on your current platform.");
}
}
#FXML
private void handleLinkAction(ActionEvent event) {
if (Desktop.isDesktopSupported()) {
if (Desktop.getDesktop().isSupported(Desktop.Action.MAIL)) { //NPE thrown here
try {
Desktop.getDesktop().mail(new URI("mailto:email#testing.yes"));
} catch (IOException | URISyntaxException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
System.out.println("The MAIL action is not supported on your current platform.");
}
} else {
System.out.println("The Desktop class is not supported on your current platform.");
}
}
#Override
public void initialize(URL url, ResourceBundle rb) {
}
}
JNLP file
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" xmlns:jfx="http://javafx.com" href="DesktopClassTesting.jnlp">
<information>
<title>DesktopClassTesting</title>
<vendor>USGS</vendor>
</information>
<security>
<all-permissions/>
</security>
<update check="always" policy="always" />
<resources>
<j2se version="1.7.0_60+" href="http://java.sun.com/products/autodl/j2se" />
<jar href="DesktopClassTesting.jar" main="true" version="0.1-SNAPSHOT"/>
<property name="jnlp.versionEnabled" value="true"/>
</resources>
<application-desc name="Desktop Class Testing"/>
<jfx:javafx-desc main-class="gov.usgs.tnm.desktopclasstesting.MainApp" name="MainApp"/>
</jnlp>
OPEN action stacktrace
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Node.fireEvent(Unknown Source)
at javafx.scene.control.Button.fire(Unknown Source)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1800(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
at com.sun.glass.ui.win.WinApplication$4$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
... 48 more
Caused by: java.lang.NullPointerException
at java.awt.Desktop.getDesktop(Unknown Source)
at gov.usgs.tnm.desktopclasstesting.FXMLController.handleButtonAction(FXMLController.java:30)
... 57 more
MAIL action stacktrace
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Node.fireEvent(Unknown Source)
at javafx.scene.control.Hyperlink.fire(Unknown Source)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1800(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
at com.sun.glass.ui.win.WinApplication$4$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
... 48 more
Caused by: java.lang.NullPointerException
at java.awt.Desktop.getDesktop(Unknown Source)
at gov.usgs.tnm.desktopclasstesting.FXMLController.handleLinkAction(FXMLController.java:51)
... 57 more
I can post the FXML file and MainApp.java if need be. I've been working on this for a days with no success, so any insight would be great. Thanks.
As it turns out this was a known bug that was corrected in the recent release of Java 7_65 and Java 8_11. Here is a link to the bug description in the database.
http://bugs.java.com/view_bug.do?bug_id=8019274

using java applet in google app engine project

I have a question about using java applet on google app engine. I created 2 classes called InteractiveGraphView1 and SimpleApplet. Using an object of InteractiveGraphView1 inside SimpleApplet. Anyway, I'm using some external jars for these 2 classes. I created a jar for my project called "GraphApplet". Then I put this jar into WEB-INF/lib and also I add it into gae project as external jar. To be sure I also added external jars that I used in GraphApplet class into my gae project. I deployed the gae project and when I tried to run applet it gives me this error:
load: class SimpleApplet.class not found.
java.lang.ClassNotFoundException: SimpleApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassNotFoundException: SimpleApplet.class
java.lang.RuntimeException: java.lang.NoClassDefFoundError: edu/uci/ics/jung/algorithms/layout/Layout
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: edu/uci/ics/jung/algorithms/layout/Layout
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: edu.uci.ics.jung.algorithms.layout.Layout
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 20 more
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: edu/uci/ics/jung/algorithms/layout/Layout
What should I do?
P.S. I forgot to tell that I'm using JUNG library in my GraphApplet project. I also added this into google app engine project
Adding into HMTL
<html>
Hello App Engine
This is my page<br>
Below you see an applet<br>
<br>
<Applet Code="SimpleApplet.java" archive="graphic.jar" width=200 Height=200>
</Applet>
Applet is just a jar file that is downloaded by browser and executed on client side as applet.
It has nothing to do with server code. From the point of server it's just a static file. So you should not pout it inside WEB-INF/lib, where server libs reside. Just put it next to your html files.
For an applet referring to other jars see: How do I build an applet which needs an external jar, using ant?
Just put your applet.jar to root of WAR directory

Java Web Start Error FileNotFoundException

So Im trying to use webstart on this application of mine and I keep getting this error:
java.io.FileNotFoundException:
http://www.fenixflame.net/DropLogger/Drop Logger.jar at
sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method) at
sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown
Source) at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source) at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown
Source) at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown
Source) at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown
Source) at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown
Source) at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown
Source) at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown
Source) at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown
Source) at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown
Source) at com.sun.deploy.net.DownloadEngine.getResource(Unknown
Source) at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown
Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown
Source) at java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source) Caused by:
java.io.FileNotFoundException:
http://www.fenixflame.net/DropLogger/Drop Logger.jar at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source) at java.net.HttpURLConnection.getResponseCode(Unknown Source)
... 15 more
This is my First time using webstart. I tested it out with simple applications and it worked just fine. I think it might have something to do with the fact that the application tries to read a local file when its launched.
Cannot post more than 2 links but you can check it out here:
fenixflame.net/DropLogger/launch.html
Yes problem was the space on the .jar file. I changed it and it worked just fine.
Its not possible to change the .jar file name inside netBeans, you can only change the project name but that doesnt change the file name. The only way to do change the .jar name is going to the project .xml file or creating a new project with the name you want for your jar file and copying all ur packages there.

Categories

Resources