I wrote a JavaFX program which also utilizes JSON. When run at startup, the try catch around the JSON parsing piece of the code throws an exception. I can't see the exception printed in the console but I made a graphical alert that pops up when the exception occurs. Any idea why this would happen even thought the program runs normally if run manually? How can I solve this?

  • What's the exception? If you can't get the popup to display the exception, how about logging it to a file?
    – Jacobm001
    Feb 15, 2017 at 16:31
  • I used e.toString I received:"Unexpected token END OF FILE at position 0.
    – nawf
    Feb 15, 2017 at 16:55
  • Are you using relative, or absolute paths?
    – Jacobm001
    Feb 15, 2017 at 16:56
  • Had quite the hassle with this one but ended up using : File file = new File("buttonConfigurationsPI.json") and a scanner + string builder
    – nawf
    Feb 15, 2017 at 16:59
  • My guess is that your application doesn't have permission to put a new file whereever cron is using as its working dir. Try creating a new directory that has 777 permissions, and then use an absolute path to write to that directory. If that works, we'll have a fairly good idea as to what's going on.
    – Jacobm001
    Feb 15, 2017 at 17:11

1 Answer 1


the answer was simple as usual. The scripts that were tested in order to run the jar at startup were running it from another directory. I used crontab plus a shell script where I 'cd'ed to the jar directory then ran the jar file. Before, I only ran the jar file using its full path, but apparently I have to cd there in order for it to find the JSON files.

  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Jan 28, 2020 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.