9

I made a java application in NetBeans on Windows which I need to deploy on Ubuntu. In my java application I have given the path where an excel file will get saved on the click of the button. My address path is like this D://Excel. This is working fine in windows and file is getting saved at the given passed address. Now my problem is this i don't know how can I get the address path in ubuntu. Any help will be highly appreciated.

Srinivas
  • 1,780
  • 1
  • 14
  • 27
Adarsh
  • 117
  • 1
  • 2
  • 9

2 Answers2

16

take your terminal and type

pwd

This will give your home folder path. Use that in your program.. It will be something like this /home/adarsh..

Konza
  • 2,143
  • 17
  • 30
  • What if the file was not saved in `/home/adarsh` and some place else? Why do you think your solution would work? – Sujay Nov 07 '12 at 06:07
  • thanx you sir for ur quick response..Sir how to get the path of 'excel' folder where i need to save the file – Adarsh Nov 07 '12 at 06:07
  • You should ideally pick up the location of the excel file from [Config](http://commons.apache.org/configuration/). – Srinivas Nov 07 '12 at 06:10
  • I think you have hard coded the locationn in your code. Create a directory in your home folder and save your excel file there. Please dont hard code the location. Its a bad practice – Konza Nov 07 '12 at 06:11
1

The question seems like : How to construct a relative path in Java from two absolute paths (or URLs)?

Please refer above link. Hope this helps you.

Community
  • 1
  • 1
Bhavesh Shah
  • 3,299
  • 11
  • 49
  • 73