when i try to run my code system shows this ///////// Exception in Application s
ID: 3776004 • Letter: W
Question
when i try to run my code
system shows this
/////////
Exception in Application start method
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 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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Input stream must not be null
at javafx.scene.image.Image.validateInputStream(Image.java:1128)
at javafx.scene.image.Image.<init>(Image.java:706)
at MazeGUIPane.start(MazeGUIPane.java:31)
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
Exception running application MazeGUIPane
///////////////
and this is my code
///////////////
import java.io.InputStream;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class MazeGUIPane extends Application{
@Override
public void start(Stage primaryStage){
WebView mapView = new WebView();
WebEngine webEngine = mapView.getEngine();
String url = "http://street360.net/spain/navarre/pamplona_navarre.php";
url += "&output=embed";
webEngine.load(url);
VBox vBox = new VBox(5);
vBox.getChildren().add(mapView);
InputStream instream = MazeGUIPane.class.getResourceAsStream("traffic.png");
Image trafficImage = new Image(instream);
instream = MazeGUIPane.class.getResourceAsStream("roads.jpg");
Image roadsImage = new Image(instream);
////////////////va
Marker RedMarker = new Marker(trafficImage, "Red");
RedMarker.setLayoutX(320);
RedMarker.setLayoutY(440);
////////////////va
Marker pamplonaMarker = new Marker(roadsImage, "pamplona");
pamplonaMarker.setLayoutX(450);
pamplonaMarker.setLayoutY(400);
///////////////// va
Group root = new Group();
root.getChildren().add(vBox);
root.getChildren().add(RedMarker);
root.getChildren().add(pamplonaMarker);
Scene scene = new Scene(root);
primaryStage.setTitle("Hello street of Pamplona!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args){
launch(args);
}
class Marker extends Group{
public Marker(Image image, String text){
ImageView imageView = new ImageView(image);
Label label = new Label(text);
VBox vbox = new VBox(5);
vbox.getChildren().add(imageView);
vbox.getChildren().add(label);
getChildren().add(vbox);
}
}
}
/////////
plz help and fix it
Explanation / Answer
roads.jpg and traffic.png dhould be resided in the path where the program is stored
Also close the class in which main() method is written
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.