jnlp unaivalable service exception
-
13-09-2019 - |
Question
I am trying to use the FileOpenSerivce, but I always get an UnaivableServiceException regardless of whether I run it from Eclipse, or from my local webserver using the jnlp file.
I am using an unsigned jar, which from what I understand is ok.
I got a debugger connected, and when running under Webstart, everything seems to succeed just fine. I am attempting to get FileContents like so:
FileContents fileContents = fileOpenService.openFileDialog(null, null);
I never see a dialog, and fileContents is always null.
Thanks!
Solution
So this whole thing was a threading problem. In my main class, MainFrame, my main method was
public static void main (String[] args) {
new MainFrame ();
}
I replaced it with this:
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MainFrame();
}
});
And it all works fine now.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow