简体   繁体   中英

Java- Data Storage and Running the Program Automatically?

So I want to do a program in Java that does the following: 1. Opens each day when the user accesses his computer after a certain time (eg 5pm) 2. Asks the user for string input (the highlight of his day) 3. logs it and Saves it then closes 4. Opens the next day on the first time the user accesses his computer and shares a random entry from previous entries with the time and date of the input (eg ice cream with the kids Monday 8/4/2013) 5. repeats

I am not certain what topics or domains I need to look for tutorials on to cover numbers 1,3,4. In other words, what topics should I check to do the following:

  1. make the program run by itself after a certain time (5pm) + when it is run for the first time the next day (I am operating on a mac do I need to look into cocoa os for this?

  2. Storage; something like persistent storage in swift - do I just look into that or do I need to get into databases?

I am looking primarily for the main topics that I need to look further into to get this done (guidance for resources, not the code). Thanks!

To have a program run at a scheduled time, you would use a program like crontab . This is available on most Unix based operating systems including OSX. Basically you enter the scheduled time, and give it an executable to run at that time. You might have it run something like java -jar /path/to/your/java/program.jar

As for storage, you can store things in many ways. The simplest way is to read to/write from a file. Java has library classes that can handle this ie FileReader , FileWriter .

Another way is to use a database (SQL, SQLite, MongoDB). To do this you will need to install a database, and use a database driver in your java program. A good search term is JDBC .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM