0

I've bundled a JavaFx application as a .exe (using ecliplse + Inno), the application is working fine but when an exception is raised I don't get the line number of my code where the exception initiated (it shows "Unknown Source"):

java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1012)
    at utils.ConfigLoader.<clinit>(Unknown Source)
    at ui.MainApplication.start(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
    at com.sun.javafx.application.LauncherImpl$$Lambda$131/998964132.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/1542341592.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
    at com.sun.javafx.application.PlatformImpl$$Lambda$49/625615544.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
    at com.sun.javafx.application.PlatformImpl$$Lambda$48/1565153168.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$145(WinApplication.java:101)
    at com.sun.glass.ui.win.WinApplication$$Lambda$37/797007557.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)

I'm redirecting the exception to a TextArea using the below code:

public static void showDialog(Exception e){
    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle("Exception Dialog");
    alert.setHeaderText("A fatal error occured, please send to the application developper");
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();
    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(expContent);

    alert.showAndWait();
}
Rima
  • 457
  • 2
  • 7
  • 18
  • possible duplicate of [(Unknown Source) in Exception stack trace](http://stackoverflow.com/questions/3132302/unknown-source-in-exception-stack-trace) – Maxim Mar 09 '15 at 11:51
  • @maxd yup it is :), the debug="true" did it for me. please put an answer and I'll accept it – Rima Mar 09 '15 at 13:49

0 Answers0