If you're just learning, I recommend that you put the details of deployment to one side at first and just assume that the database will always be there and will always be in the correct format. Once you've got your application to a state where you're reasonably happy with it, then you can address your concerns regarding the database.
When you do get to addressing these concerns, a general approach would be for your application to have a database setup script, this will be a set of SQL statements for creating the tables, indexes, permissions etc. Assuming that you're using JDBC, your application settings should specify the JDBC connection details (for example, JDBC Url, username and password). Your application should connect to this source and then run the setup script.
One caveat with your setup script is that it should work regardless of the state of the database. Suppose you have lots of statements of the form
CREATE TABLE FOO (id int....)
If the table FOO already exists, you'll get an SQLException which you'll need to catch and ignore (but only for the specific case where the table exists, you can't ignore other errors).
Suppose a later version of your application needs a slightly different definition of FOO. In that case, you can't just change the CREATE statement, you'll need to keep your original CREATE statement followed by some ALTER statements.
This approach assumes that it will be possible for your application to connect to the JDBC data source. If you are planning for your application to use a standalone DBMS such as MySQL, Postgres, Oracle, SQL Server etc. then I would consider installing the DBMS to be the responsibility of the user of your application. The user will also need to figure out what the JDBC URL should be and provide that to your application.
If you want to avoid the user having to install a DBMS then it's possible to embed a pure Java DBMS with your application. JavaDB (AKA Derby) is one example, HSQLDB and H2 can also be used in this way. To take Derby as an example, you would need to include the derby libraries (jars) with your application and your application would need to create the database when it starts up. If you're using Derby in "embedded mode" your URL would look something like:
jdbc:derby:/home/fred/myapplicationdb
As far as I remember, the Derby library will create the database if it doesn't exist.