Basically, where should you save your Java Databases? Should you save them in the project directory or on any location within your computer?
I have decided to write an article, demonstrating where you should save your databases for any java project on any IDE.
Why Does Does Database Location Matter in any Java Project?
Well, the database location is very much important especially when it comes to distributing your Java Project. We must all agree that it’s simple to distribute your project with database saved outside the Java project files.
Now the option left for us is to save the database inside the Java Project files. But Where Exactly? This article is going to illustrate the exact location you should save your database inside ava Project files, probably on any IDE.
Exact Location You Should Save Your Databases in Any Java Project
To understand where you should save your databases in any Java Application project, let’s first understand the file structure for any java project used by most IDEs. For our example, we are going to focus on three IDEs, i.e. Eclipse IDE, NetBeans IDE, and IntelliJ IDEA.
Eclipse IDE File Structure
NetBeans File Structure
Intellij IDEA File Structure
You probably have noticed a kind of correlation between the three IDEs. Now the question still triggers, where should you save your database in any IDE’s Java Project?
The solution on Where You Should Save Your Database in any Java Project
If you are developing any serious java application, you’re probably using any of the above IDEs. The Ideal Location to save your database should be in the same directory as src. Your database file should be contained in the main project directory. This should be applied to all three IDEs (Eclipse, NetBeans and IntelliJ IDEA).
Have a look at the Screenshots below
The following screenshots show a file structure for the 3 IDEs with the database. The screenshots represent Eclipse IDE, NetBeans IDE, and IntelliJ IDEA respectively.