简体   繁体   中英

Application path given by user during application installation

I am deploying a Java application. User chooses the installation directory of the app. I want to get that path so that i can pass the path for making a sqlite DB der.

Mostly it will be something like :

C:\Program Files\My App Name

or

C:\Program Files(x86)\My App Name

The problem is I cannot hardcode the DB location in my code, beacuse i want my application to have the flexibility to be installed on user's choice of path.

You can pass path dynamically in the run configuration of the Eclipse/IDE

-Dfilepath="C:\Program Files\My App Name"

Right click on project in the Explorer window --> Run As --> Run Configuration. Then go to Arguments tab.

Edit : Suppose you get the path of DB from user and then put it in the file C:\\Config\\config.txt . Now this txt file has your actual path where you want to create your db. So through your java program you can read this file and get the path.

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