Closed Tempura-Person closed 1 year ago
for some context: how 'bye' works is that all user input is handled by the Parser class.
The Parser class has a loopEnd boolean that signals when the 'bye' command has been entered, before updating it to true.
At the end of every command of user input, the main method (in the Duke class) updates to be the same as loopEnd in the Parser class, so when loopEnd in Parser is true, the loop to accept user input also stops in the main method.
as for the autosave, it is also handled by Parser automatically every time a command is handled.
i assume the error is because the filepath "data/duke.txt" cannot be accessed, but isn't this already a relative filepath?
Check if you have handled the case where the folder doesn't exist, as the .jar file likely won't have a /data folder in the directory it is situated.
From the module website:
Your code must handle the case where the data file doesn't exist at the start. Reason: when someone else takes your Duke and runs it for the first time, the required file might not exist in their computer. Similarly, if you expect the data file to be in as specific folder (e.g., ./data/), you must also handle the folder-does-not-exist-yet case.
try 1.check if directory exist if not mkdir 2.check if file exist if not create files
do allow to print the original exception msg as it will give you more info during debugging. hope this can help :)
that did it, i didnt check if the file and directory existed first time around, now it works in .bat autotesting and the exported .jar file. Thanks!
Hello! It appears that your issue have been resolved :D
Perhaps @Tempura-Person can mark this issue as Close as completed
. Thank you!
(But it you think your question is still not answered, perhaps you can reiterate what you would like to clarify.)
@Tempura-Person A gentle reminder to close this issue if the problem has been resolved. If not resolved yet, please post a comment explaining which part of the problem/question remains unresolved.
@Tempura-Person I'm closing this issue due to inactivity. Feel free to reopen if the issue is still unresolved.
as suggested by the instructions below, i exported my iP into a jar file using intelliJ's build artifacts function. The whole thing functions properly besides the 'bye' command (which does not terminate the process) and the autosave feature failing to work (as i set up an error message to display if it happens)
These bugs seem to be exclusive to the exported jar file (the project still works fine within intelliJ) and i don't know how to fix them properly.