• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

get directory path linux

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic