Search code examples
javasqlitejavafxormlite

JavaFx with Sqlite database deploy


I am working on a JavaFX application in which I am using SQLite database for storing some important information. Since I am working on IntelliJ, the created database file is in the root directory of the project.

SQLite database location :

jdbc:sqlite:database.db
  1. But where will be the database after installing with .deb or .exe files by default? In Linux and Windows.
  2. How to set a location for a database. So that, that location is going to be the location of the database after installing the application with .deb or .exe files.

Solution

  • you have three options. the first is to pave the path to the database as an app parameter.

    the second option is to use the user's home directory. you can create a subdirectory whose name starts with a dot (hidden directory in linux) in which to put your work files. to get the name of the home directory use

    System.getProperty("user.home") ;
    

    the last option is to use the directory where the jar file is located

    MyClass.class.getProtectionDomain().getCodeSource().getLocation().getPath();