0

I'm developing a small application to learn JavaFX with. I've run into an issue where when I run my app with an IDE (Eclipse) it works perfectly. However when I export the project to a runnable Jar file, and try to run the jar file, the window I want to pop up doesn't. I've exported it as every type of the three options eclipse allows.

I ran it through the command line to get the stacktrace:

http://pastebin.com/tfkJFnEZ

The rest of the app works great, just this one window. What is puzzling to me (as a beginner) is why it will run in Eclipse but not after exportation. I'm not sure what is changing in the way I want to open the file, so I'm not sure where to look for my error.

If there is anything else I need to provide to assist just let me know, I appreciate any advice anyone can give.

erik-sn
  • 2,590
  • 1
  • 20
  • 37
  • Can you add information on your project structure and how are you loading `SpinneretteDirectory.fxml` ? – ItachiUchiha Feb 18 '15 at 19:02
  • Sure. The app is surrounded by a menu bar "RootLayout". When the user clicks an option on that menu bar, it runs a method in the RootLayout Controller file called "handleSpinneretteDirectory()". This method then calls a method from the MainApp which contains the FXML loader, stage, etc. where SpinneretteDirectory.fxml is called. I'm considering doing away with calling the MainApp method and just getting the loader/stage inside the controller to see if that helps. – erik-sn Feb 18 '15 at 19:11
  • With the structure I mean the package layout, where is the particular fxml located and what exactly is the FXMLLoader statement that you are using. – ItachiUchiha Feb 18 '15 at 19:14
  • `SpinneretteDirectoryController.java:39`, what is the code on that line where you are getting a [NullPointerException](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it)? – jewelsea Feb 18 '15 at 19:17
  • This is my package layout: http://i.imgur.com/4uvFeBM.png; the code to load the fxml file is this: http://i.imgur.com/nBRSVuz.png - it is located in the MainApp.java. Line 39 is shown here: http://i.imgur.com/KK8PyKg.png - it is adding an observable list from MainApp to a TableView named tableView. One concern I just thought about was that this list is static...is it possible that it could cause an issue like that from a Jar file but not in Eclipse? – erik-sn Feb 18 '15 at 22:48
  • Please edit your question and include enough code to reproduce the problem. Are you running with the same version of the JDK in both cases? – James_D Feb 19 '15 at 00:06

1 Answers1

0

So what I found was that when I tried to set data into the TableView (shown as an error at line 39 in the stacktrace) it was throwing the error. It turns outthe TableView was set as static. I honestly am not sure why I set it up this way, but as soon as I removed the "static" in front of it the windows pops open and works. I feel a little silly that it was something so simple.

However, I'm still confused as to why a static TableView that works in Eclipse fail to work on a Jar file. Anyone have any ideas?

erik-sn
  • 2,590
  • 1
  • 20
  • 37
  • You are probably running different versions of the JDK; a 1.7 version in Eclipse and a 1.8 version when running your jar file. (You can check this easily enough.) As detailed in [this question](http://stackoverflow.com/questions/23105433/javafx-8-compatibility-issues-fxml-static-fields/23109125#23109125), `@FXML`-injection to static fields worked in version 1.7 as a side-effect of the particular implementation; in Java 1.8 it no longer works. – James_D Feb 19 '15 at 03:13