I recently started learning JavaFX and my class was given the following assignment:
Write a program that displays four images in a grid pane.
Here is my code:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class Ch_14_Ex_1 extends Application {
#Override //Override the start method in the Application class
public void start(Stage primaryStage) {
//Create a pane to hold the image views
GridPane pane = new GridPane();
//Place nodes in the pane
pane.add(new ImageView(new Image("image/ukFlag1.gif")), 0, 0);
pane.add(new ImageView(new Image("image/canadaFlag1.gif")), 1, 0);
pane.add(new ImageView(new Image("image/chineseFlag1.gif")), 0, 1);
pane.add(new ImageView(new Image("image/usaFlag1.gif")), 1, 1);
//Create a scene and place it in the stage
Scene scene = new Scene(pane);
primaryStage.setTitle("Ch_14_Ex_1"); //Set the stage title
primaryStage.setScene(scene); //Place the scene in the stage
primaryStage.show(); //Display the stage
}
}
The program compiles fine but whenever I try to run the program I get the following error and i'm not sure how to fix it.
Exception in Application start method
Exception in thread "JavaFX BlueJ Helper" 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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1118)
at javafx.scene.image.Image.<init>(Image.java:620)
at Ch_14_Ex_1.start(Ch_14_Ex_1.java:16)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
... 1 more
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1110)
... 11 more
You can set the resources folder in your project in case you wanna wrap it in your jar file and load them like so
new Image(getClass.getResourceAsStream("image/yourImage.gif"))
OR
If those images are not in your resources you can load them like so
new Image("file:image/yourimage.gif")
Related
I have some trouble with launching a javafx application. To explain, I wrote a code that worked but I was on Ubuntu 19.04 and I decided to reinstall my Linux version (20.04). I copied my code and reinstalled e(fx)clipse, scenebuilder, openjfx, and imported the same jfxrt.jar but nothing worked. I can't manage to launch javafx application, even if the code is empty (ig code). Oh and I have to use java 8 for this homework.
Can you help me please?
Here is my code
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
public class LaunchApplication extends Application {
public static void main(String[] args) {
launch(args);
}
//Empty but still error
#Override
public void start(Stage arg0) throws Exception {
}
//Old code, doesnt work anymore
// #Override
// public void start(Stage primaryStage) throws Exception {
// try {
//
// FXMLLoader loader = new FXMLLoader();
// loader.setLocation(getClass().getResource("view/Login.fxml"));
// Parent root = loader.load();
//
// Scene scene = new Scene(root);
// primaryStage.setScene(scene);
// primaryStage.setResizable(true);
// primaryStage.show();
//
// } catch (Exception e) {
// System.out.println(e);
// }
//
// }
}
And there my error when running it
Exception in thread "main" 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 sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: <init>
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:288)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
Caused by: java.lang.NoSuchMethodError: <init>
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
at java.lang.Runtime.load0(Runtime.java:810)
at java.lang.System.load(System.java:1088)
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:107)
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:39)
at com.sun.glass.ui.gtk.GtkApplication.lambda$new$5(GtkApplication.java:156)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:140)
at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
at com.sun.glass.ui.Application.run(Application.java:146)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:278)
... 9 more
```
Hello everyone im trying to make a simple video player with javafx and then add some controls later with scene builder however I cant even get the simple video to play , I keep getting an error saying
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.IllegalAccessError: class com.sun.media.jfxmediaimpl.NativeMediaManager (in unnamed module #0x22fda225) cannot access class com.sun.glass.utils.NativeLibLoader (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.utils to unnamed module #0x22fda225
at com.sun.media.jfxmediaimpl.NativeMediaManager.lambda$new$0(NativeMediaManager.java:110)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at com.sun.media.jfxmediaimpl.NativeMediaManager.<init>(NativeMediaManager.java:107)
at com.sun.media.jfxmediaimpl.NativeMediaManager$NativeMediaManagerInitializer.<clinit>(NativeMediaManager.java:78)
at com.sun.media.jfxmediaimpl.NativeMediaManager.getDefaultInstance(NativeMediaManager.java:90)
at com.sun.media.jfxmedia.MediaManager.canPlayProtocol(MediaManager.java:78)
at com.sun.media.jfxmedia.locator.Locator.<init>(Locator.java:239)
at javafx.scene.media.Media.<init>(Media.java:393)
at javaapplication3.JavaApplication3.start(JavaApplication3.java:45)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Exception running application javaapplication3.JavaApplication3
C:\Users\adamk\OneDrive\Documents\NetBeansProjects\JavaApplication3\nbproject\build-impl.xml:1341: The following error occurred while executing this line:
C:\Users\adamk\OneDrive\Documents\NetBeansProjects\JavaApplication3\nbproject\build-impl.xml:936: Java returned: 1
BUILD FAILED (total time: 1 second)
I made sure that the path is correct and everything but it still wont play. can someone please help ? thanks !!!
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
/**
*
* #author adamk
*/
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.File;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.property.DoubleProperty;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.Group;
import javafx.scene.media.MediaView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import java.io.File;
public class JavaApplication3 extends Application
{
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
String path = "C:\\1.mp4";
//Instantiating Media class
Media media = new Media(new File(path).toURI().toString());
//Instantiating MediaPlayer class
MediaPlayer mediaPlayer = new MediaPlayer(media);
//Instantiating MediaView class
MediaView mediaView = new MediaView(mediaPlayer);
//by setting this property to true, the Video will be played
mediaPlayer.setAutoPlay(true);
//setting group and scene
Group root = new Group();
root.getChildren().add(mediaView);
Scene scene = new Scene(root,500,400);
primaryStage.setScene(scene);
primaryStage.setTitle("Playing video");
primaryStage.show();
}
}
I can't run JavaFX application. I just want to store some data into table and see it.But only I got mistake someone please help me.
this is my controller class
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import java.net.URL;
import java.util.ResourceBundle;
public class Controller implements Initializable {
#FXML
TableView<Person> table;
#FXML
TableColumn<Person,Integer> number;
#FXML
TableColumn<Person,String> name;
#FXML
TableColumn<Person,String> surname;
#Override
public void initialize(URL location, ResourceBundle resources) {
table = new TableView<>();
number = new TableColumn<>();
name = new TableColumn<>();
surname = new TableColumn<>();
number.setCellValueFactory(new PropertyValueFactory<Person, Integer>("id"));
name.setCellValueFactory(new PropertyValueFactory<Person, String>("name"));
surname.setCellValueFactory(new PropertyValueFactory<Person, String>("surname"));
ObservableList<Person> data = FXCollections.observableArrayList(new Person(1,"fa","fafe"));
table.setItems(data);
table.getColumns().addAll(number,name,surname);
}
}
but I'm getting following errors which I get from terminal I gave every id to my components
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
at com.sun.javafx.application.LauncherImpl$$Lambda$1/1927950199.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException: Error resolving onEditStart='#click', either the event handler is not in the Namespace or there is an error in the script.
/D:/work%20proyeqt%20immidetely/WorkWithTable/out/production/WorkWithTable/sample/sample.fxml:15
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2591)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:104)
at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:606)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:766)
at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2817)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2526)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2435)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3208)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
at sample.Main.start(Main.java:13)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/355529278.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/2000304245.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/225942701.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/2051067688.run(Unknown Source)
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$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$38/517043427.run(Unknown Source)
... 1 more
this is error just keeping occur in my terminal.what it might be wrong please help me to solve this. I just want to store some data into my table that's it and see the result in application.
welcome to Stack Overflow!
The important line in your error message is this one:
Caused by: javafx.fxml.LoadException: Error resolving onEditStart='#click', either the event handler is not in the Namespace or there is an error in the script.
/D:/work%20proyeqt%20immidetely/WorkWithTable/out/production/WorkWithTable/sample/sample.fxml:15
This means that there is an error on line 15 of sample.fxml, specifically where it says onEditStart='#click'. Either it can't resolve 'onEditStart' or click() isn't a function in the controller.
I have also run into some problems trying to get my JavaFX program to run. Like some of the others, I keep getting an error of java.lang.NullPointerException: Location is required. The fxml file is in the Application package. I've tried all the remedies I've found in here, but maybe I'm missing something? Here is my code
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("application/Main.fxml"));
Scene scene = new Scene(root, 400, 400);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
And here is the Error
java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
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 application.Main.start(Main.java:18)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Any help would be much appreciated. Thanks in advance
I lost an entire day battling with this issue in Netbeans. This is how I solved it : Firstly, I put the fxml file in the same package with main (though it can work even in separate packages). Secondly, I used getClassLoader() specifying the path of the file. Here's the code :`
public class Main {
public static void main(String[] args) {
System.out.println("Test = "+Main.class.getClassLoader().getResource("FXMLDocument.fxml"));`
After Running the project, here's the output : ....NetBeansProjects/JavaFXApplicationTest/dist/JavaFXApplicationTest.jar!/FXMLDocument.fxml
Note that Running the file alone was generating an error before.
this will work:
"/application/Main.fxml"
you just need to add a /
Solved the problem by dragging and dropping Main.fxml in src folder.
I seem to be having problems figuring out why the heck I keep getting these java.net.ConnectExceptions. I'm running Windows 7 with a clean install of Java 7u6 x64. I've turned off my firewall (in case that was the issue). I've followed the solutions posted here:
java.net.SocketException: Invalid argument: connect
But nothing is getting rid of these issues. I've even used the Microsoft FixIt application to reset my IP stack. I've also added the "-Djava.net.preferIPv4Stack=true" to the environment variable JAVA_TOOL_OPTIONS variable. Nothing has worked.
This is a JavaFX "Hello World" program from the Netbeans IDE. (On my Mac I have no problems.)
Any help would be GREATLY appreciated! I'm no longer sure where to look to solve this. The end result is that every JavaFX program takes a long time to run. It appears they are all waiting for the timeouts of the socket connections before moving forward with the application. This is not occurring with Java programs, only JavaFX.
Here is the code:
package anotherjavafxtest;
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.StackPane;
import javafx.stage.Stage;
/**
*
* #author redacted
*/
public class AnotherJavaFXTest extends Application
{
#Override
public void start(Stage primaryStage)
{
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>()
{
#Override
public void handle(ActionEvent event)
{
System.out.println("Hello World!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application. main() serves only as fallback in case the application can not be launched through deployment
* artifacts, e.g., in IDEs with limited FX support. NetBeans ignores main().
*
* #param args the command line arguments
*/
public static void main(String[] args)
{
launch(args);
}
}
And here is the Exception list:
java.net.ConnectException: Connection refused: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:203)
at sun.net.www.http.HttpClient.New(HttpClient.java:290)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:995)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:974)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2380)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1546)
at com.sun.deploy.net.proxy.AbstractAutoProxyHandler.getJSFileFromURL(Unknown Source)
at com.sun.deploy.net.proxy.AbstractAutoProxyHandler.init(Unknown Source)
at com.sun.deploy.net.proxy.DynamicProxyManager.reset(Unknown Source)
at com.sun.deploy.net.proxy.DeployProxySelector.reset(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.javafx.main.Main.tryToSetProxy(Main.java:572)
at com.javafx.main.Main.launchApp(Main.java:640)
at com.javafx.main.Main.main(Main.java:805)
It's FX vs system proxy issue, FX is trying to check system proxy and failing if it's misconfigured. The reason for that is next enhancement: http://javafx-jira.kenai.com/browse/RT-21705
Add next to JVM arguments in project properties: "-Djavafx.autoproxy.disable=true" or fix system proxy to resolve that.
Shouldn't you be running different app than you supposed, cause that sample code has nothing to do with network connection. Also check the JavaFX Runtime Platform of the Netbeans and hence of your app. You can find it in "Java Platforms" under "Tools" menu.