File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes get directory path linux Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "get directory path linux" Watch "get directory path linux" New topic
Author

get directory path linux

gadarla
Greenhorn

Joined: Mar 05, 2007
Posts: 3
hi all

please help me
i have one problem
while creating directory in linux

File dir = new File(System.getProperty("/home/usr1") +File.separatorChar + "jdb1");
dir.mkdirs();
in above /home/usr1 takes null
is there any way to acess folder path from application and create
directory under that

Thanking you
swarna dasa
Ranch Hand

Joined: Mar 15, 2007
Posts: 108
Don't think this is a SCJP question.

Anyway here is the answer.

public static String getProperty(String key)

Gets the system property indicated by the specified key.

So System.getProperty(key), gets the value for the key, which in this case is null.

while running your java application
use -D option to set System properties
eg java -DAPPLICATION_HOME="/home/usr1" YourJavaFileName

Is your Application accessing the file (directory) resources on the same machine it is running on?
If yes, then you can create a directory
File dir = new File("/home/usr1" +File.separatorChar + "jdb1");
dir.mkdirs();

if not then the application has to send the file/dir path to the server via RMI and then the server will create the directory
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: get directory path linux
 
Similar Threads
file path
File constructor
What's wrong with it?
Installing Java on Linux
confuse on how to set the java_home classpath correctly