Determin current working directory using java program

HI:
I would like to know is there anyway that I can determine what my current working directory is, using a java program??
Thanks,
Sincerely,
Karen

Properties sysProperties = System.getProperties();
String currDir = sysProperties.get("user.dir");Here's a list of all the properties you can get from sysProperties:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties()

Similar Messages

  • Java.lang.Error: Properties init: Could not determine current working direc

    Hi,
    We have an application which will copy all the files from a directory on the main server (manager) to all other servers in the cluster.The process is little bit tricky in the sense that all servers will pull the data from manager, copy it to a pending directory and then shut down the rmi process on them, rename pending directory with the original name (some name) and start the rmi process. All the communication is done using RMI calls. We use a GUI tool on windows to initiate this process. We are also running some shell scripts from java in this process. We run this process daily.
    The problem is, once in a while we are getting the follwing error on some of the servers in the cluster and the data updates are not happening any more.
    Error occurred during initialization of VM
    java.lang.Error: Properties init: Could not determine current working directory
    We had to start the rmi process on the server again where it failed with the above error and Initiate the process again from GUI. Any ideas, why we get this error? Also, why only once in a while? Our application is running under root context, so i think, running as "root" is not an issue as I see on some of the forums. Any help is greatly appreciated.
    Thank you

    It is possible to remove or rename the working directory of a running process. It (or a child process) might then have trouble when looking for its current working directory.
    posman@linux:~> mkdir scratch
    posman@linux:~> cd scratch/
    posman@linux:~/scratch> pwd
    /home/posman/scratch
    posman@linux:~/scratch> rmdir `pwd`
    posman@linux:~/scratch> bash
    shell-init: could not get current directory: getcwd: cannot access parent directories: No such file or directory
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_MESSAGES to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    dirs: could not get current directory: getcwd: cannot access parent directories: No such file or directory
    posman@linux:~/scratch>

  • How to create a directory or Folder  using java program?

    Hi all,
    Can any one know, how to create a directory(new folder) in java.
    can any give me some idea, on creating a directory using java program dynamically.
    thanx in advance

    hi thanks for your answer,
    sorry, actual i know this technique(its my fault i didnt mentioned it)
    i am looking for some what different technique.
    bye
    ram

  • Installing sp19 to ep60: could not determine current working direcory

    Hi,
    upgrading EP 6.0 from SP15 to SP19 using sapinst I get the following error message:
    ERROR 2007-08-23 10:19:27
    CJS-20076  Error while retrieving the mode of the Java EE Engine.<br>SOLUTION: See output of logfile /tmp/sapinst_instdir/PATCH/ORA/getEngineMode.log: 'Error occurred during initialization of VMjava.lang.Error: Properties init: Could not determine current working directory.'.
    Can someone help?
    Renate

    Hi Renate,
    This very much sounds like a permission problem. The user with whom you have started SAPINST (and which then started a JVM) seems not to have the permission to read ithin the JVM working directory. Google for "Properties init: Could not determine current working directory" leads to different similar problems.
    Check that you start SAPINST with an administrative user (should be the one with whom the installation happened).
    Hope it helps
    Detlev

  • How to send fax using java programming

    i need to send files in my hard disk through fax using java programming.
    i have found on the internet that it is possible to be implemented by using java.comm API and JTAPI. however, i don't know how...does anyone can tell me the details? also, as i know it will be a big project to send fax using such API. is that any other simple way to implement the fax function in java? thx a lot!

    To cse.mahbub:
    Are you aware that you replied to a 5 1/2 year old question?
    Please don't do that. Reply only to current questions.

  • To get JRE or JDK version using Java Programs

    How do get JRE or JDK version using Java Programs?.
    Kindly Reply...
    By
    Mani

    If you're talking about current program's runtime environment (as opposed to all installed JDK/JRE) : System properties

  • Setting persitent system environment variables using java program

    hai,
    Iam tryng to write installation for an application,which require to set some persistent system environment variables using java program. I have tried using set command Runtime.getRuntime().exec("cmd /c set blah blah "),but this applies only to that particular DOS promt only,i presume.And this is not perisistent.please do help.
    Biju

    The solution I proposed worked only on Windows XP/2003.
    The following solution will work on Windows NT/2000/XP/2003 with JDK 1.2+.
    1- Download the [url http://www.gjt.org/download/time/java/jnireg/registry-3.1.3.zip]JNIRegistry zipped archive.
    2- Open the registry-3.1.3.zip file and extract in the folder of your choice ( Eg. c:\setenv ) only the 2 first files (when sorted by path): ICE_JNIRegistry.dll and registry.jar.
    You don't need to keep the folder tree in the extraction.
    3- Create the following SetEnv.java file in the same folder ( Eg. c:\setenv ).
    import com.ice.jni.registry.Registry;
    import com.ice.jni.registry.RegistryKey;
    import com.ice.jni.registry.RegStringValue;
    import com.ice.jni.registry.RegistryValue;
    public class SetEnv
        static final String REG_HKLM_SUBKEY_NAME = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
        public static void main(String[] args)
        throws Exception
            new SetEnv().exec(args);
        void exec(String[] args)
        throws Exception
            if (args.length != 2)
                throw new IllegalArgumentException("\n\nUsage: java SetEnv {varName} {varValue}\n\n");
            String varName = args[0];
            String varValue = args[1];
            RegistryKey key = null;
            RegStringValue value;
            try
                key = Registry.HKEY_LOCAL_MACHINE.openSubKey(REG_HKLM_SUBKEY_NAME, RegistryKey.ACCESS_ALL);
                value = new RegStringValue(key, varName, RegistryValue.REG_EXPAND_SZ);           
                value.setData(varValue);
                key.setValue(value);
                key.flushKey();
            finally
                try { key.closeKey(); }
                catch (Exception e) {}
    }4- Compile it.
    javac -classpath .;registry.jar SetEnv.java
    5- Run it. varName and varValue are strings of your choice.
    java -classpath .;registry.jar -Djava.library.path=. SetEnv varName varValue

  • How to list the top 10 largest files in the current working directory ?

    How can I list the top 10 largest files in the current working directory in Solaris ?

    execute below....to get the large files in order.. change the <FS>
    find /<FS> -type f -size +1024 -ls | awk '{print $11, $7}' | sort -rn +1 | awk '{print $1, $2/1024/1024 "MB"}' | /bin/more

  • Creating aVirtual directory Using java

    Hai ,
    I am Using windows XP Operating system, I know how to create a directory using java,
    can you please suggest me a procedure to create a virtual(web share ) directory using java.
    waiting for your reply
    Thanks & Regards,
    Naga Raju

    Virtual Programmer is in the to share the directory
    over the Internet.No, that's a file/web server. :) I see, it's a Microsoft term.

  • Interaction with Microsoft Word using Java Programming

    writing Text ON TO MICROSOFT WORD USING java Programming Urgently required

    Go throuh jakarta POI(hssf) to do..No! HSSF which stands for Horrible SpreadSheet Format can be used for Excel (spreadsheets as the name suggests). For Word, you would need to lok at HPSF.

  • How to find cd rom drive in windows and unix platform using java program

    Hi,
    I am having the requirement of finding the cd rom drive
    using java program. I do not know the label and which
    one is the cd rom drive. also I want to know how many
    cd rom drives are there on my system. I want the solution
    for windows and unix platforms.
    If have any suggestions please mail to [email protected]
    Deepak

    Ughhh.. I had the same problem with multi platform file-system detection
    First off - Unix.
    Do you know for sure you have all your drives mounted?? This could be a big problem because java will not see unmounted drives... So you can scour thru your /etc/fstab to find out which drives are available... or you can mount all and show roots... (Yuck!)... You've got timeouts and all sorts of things to worry about...
    I would then shy away from the java.io.File.listRoots() on unix and rely on parsing your fs file. If a user would like to see the medium in the drive. Do a Runtime.exec and mount the drive, then you can grab the filesystem by wrapping it in the java.io.File object. ( NOTE - this will hold well for your NFS mounts as well which might be buried under other FS. So you now have detection for that as well. ) Labels are also noted in this file. Let me know if you don't know the difference between mtab and fstab....
    Second - Winders.... Corney but I love saying that.
    The listRoots is a good solution. As others have said CD-ROMS will not be writable. Use a combination of getName and getPath to decipher the label and mount point.
    Hope this helps!

  • How to read system eventlog using java program in windows?

    How to read system eventlog using java program in windows?
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Hi,
    There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
    The output of this command can be read using java program....
    we can use java exec for executing this system32 vbs script.
    use the below program and pass the command "eventquery"
    plz refer cscript,wscript
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    String line;
    Process p = Runtime.getRuntime().exec("Command");
    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    input.close();
    catch (Exception err) {
    err.printStackTrace();
    This sample program will list all the system log information....
    Zoe

  • How to read system evenlog using java program in windows

    How to read system evenlog using java program in windows???
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Welcome to the Sun forums.
    >
    How to read system evenlog using java program in windows???>
    JNI. (No.)
    >
    is there any java class available to do this ? or any one having sample code for this?>You will generally get better help around here if you read the documentation, try some sample code and come back with a specific question (hopefully with an SSCCE included).
    >
    Your friend Zoe>(raised eyebrow) Thank you for sharing that with us.
    Note also that one '?' denotes a question, while 2 or more generally denotes a dweeb.

  • Set system classpath using java program??

    Hi,
    I want to set the System classpath using java program. Can somebody please tell how to do this.
    Prashant

    but this will set the classpath for that particular JVM only.
    Isn't it??? I want that of SYSTEM so that user can access that class path from any JVM instance.
    Prashant

  • How to extract .sit files(in MAC)  using java program

    Hi,
    please help me , i want to simple program for
    " how to extract .sit files(in MAC) using java program"
    that sit files same as zip files in windows..[                                                                                                                                                                                                                                                                                                                                   

    Thanks for reply...
    but i search in the google about this topic...there is no results will appear..
    the problem is "i have to run program in the MacOS like extract all the
    .sit(StuffIt) extension files. These sit files same as zip files in the windows... we have one tool called StuffIt Expander but it is 3rd party tool. but here requirement is i have to write my own program to extract all the files same as zip file program...
    please do the needful..i am waiting for ur reply,,,

Maybe you are looking for

  • Problem in SXMB_MONI

    Hi Experts, I have problem in SXMB_MONI when i am sending messages from RWB the messages which have BPM Associated with it are not been visible in SXMB_MONI but the messages which do not involve BPM that which are sent from RWB are visible . what cou

  • System Wide Automator Action

    How do i get a automater installed system Wide. So every user on the machine can use it with the contextueel menu. I tryd creating /Library/Workflows/Applications/Finder/ but actions placed here are not shown in menu.

  • MB56 for quality notifications?

    Hi all, is there a possibility to see quality notifications for substream materials which were consumed for production of a finished good? I mean a kind of MB56 for quality notifications.You enter the finished goods material and batch and see if ther

  • Global setting to hide Airport, TimeMachine for all users?

    Is it possible to hide Airport, TimeMachine, and Bluetooth for all OD users? 10.5.6 Server/Clients

  • Calling a module component from a diff form

    Hi guys, Does any one know how to: call a module component of a form from a nother from using call form procedure or any diff method. Thanks