0

I've written a toDoList with Intellj in Java. I used simpleJson to save and load the tasks. In my repository I have a data folder where the json file is stored. However, when I package it with Intellj into a .jar, the save/load feature does not work. I am assuming this is because there's no json file attached in the packaging. Thus, is it possible to make a new Json file in the same folder where the .jar is so my program doesn't crash? In Intellij my code still runs if I delete the data file from the project view.

1
  • 1
    Welcome to SO. We prefer to have a minimal reproducible example to help with questions like this. Can you provide one? Thx. Commented Apr 2, 2020 at 21:59

1 Answer 1

1

Maybe using another way to store your JSON file will be better than inside a *.jar file because *jar are archives : direct serialization will not work unless you try to unpack/package the things. Bad way to go with complicated stuff for no added value.

If I were you, I will try to store these file in the user folder of your system. To get it, you can use :

System.getProperty("user.home");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.