Obtaining directory from with the source file

Discussion in 'Java' started by mshetty@mail.com, Jan 17, 2007.

  1. Guest

    Hi,

    We are new Java. We have a hierachy <Inst Dir>/CNV/src/com/xyz/abc for
    the source code and <Inst Dir>/CNV/lib/com/xyz/abc for the class files.
    The jars are created in CNV. There are some shell scripts in CNV to
    execute the class files.
    We want to do the following:
    1. Create logs in CNV.

    The <Inst Dir> could vary from one installation to another. Is there a
    way of finding out this path from the java file in <Inst
    Dir>/CNV/src/com/xyz/abc

    Thanks and Regards,
    M Shetty
    , Jan 17, 2007
    #1
    1. Advertising

  2. wrote:

    > ..We have a hierachy .. <Inst Dir>/CNV/lib/com/xyz/abc for the class files.

    ....
    > We want to do the following:
    > 1. Create logs in CNV.


    That is not a good place to put the logs.

    A better place might be something like..
    {$user.home}/com/xys/abc/ourapplication.log

    Or, better yet, let the user choose the location for
    themselves, and simply store a string naming the
    path to it, in..
    {$user.home}/com/xys/abc/logpath.txt

    Andrew T.
    Andrew Thompson, Jan 17, 2007
    #2
    1. Advertising

  3. Andrew Thompson wrote:
    > wrote:
    >
    > > ..We have a hierachy .. <Inst Dir>/CNV/lib/com/xyz/abc for the class files.

    > ...
    > > We want to do the following:
    > > 1. Create logs in CNV.

    >
    > That is not a good place to put the logs.
    >
    > A better place might be something like..
    > {$user.home}/com/xys/abc/ourapplication.log
    >
    > Or, better yet, let the user choose the location for
    > themselves, and simply store a string naming the
    > path to it, in..
    > {$user.home}/com/xys/abc/logpath.txt
    >
    > Andrew T.


    I completely agree with Andrew.

    Log files do not belong in the application directory - almost always
    there is a separate path (often separate drive which gets backed up,
    etc.) for logs. Anyway, if you still insist on putting the logs in
    installation folder, try this :
    new File(".").getAbsolutePath( );
    to get the "current" location as seen by the class calling this API.
    Take a look at java.io.File API, there are methods to get parent
    folder, etc. in there.

    -cheers,
    Manish
    Manish Pandit, Jan 18, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cloud Burst
    Replies:
    11
    Views:
    1,015
  2. Shaun Heveron
    Replies:
    6
    Views:
    472
    Lieven
    Oct 28, 2004
  3. Ryan Kaskel

    Obtaining Webpage Source with Python

    Ryan Kaskel, Jun 24, 2004, in forum: Python
    Replies:
    4
    Views:
    359
    Phil Frost
    Jun 24, 2004
  4. Bogdan Tudor
    Replies:
    7
    Views:
    378
    Tom Hawtin
    Jan 11, 2007
  5. Replies:
    1
    Views:
    82
    Yukihiro Matsumoto
    Aug 7, 2006
Loading...

Share This Page