Results 1 to 3 of 3

Thread: C# Application.StartupPath in Java

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    C# Application.StartupPath in Java

    Hello All,

    in C#, I able to get current application running path using:

    String appPath Application.StartupPath;

    how about in Java?

    please help

    thanks & regards

  2. #2
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: C# Application.StartupPath in Java

    Code:
    // To get the startup path
    String dirPath = System.getProperty("user.dir");
    
    // To do stuff with the path
    File startupPath = new File(dirPath);

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: C# Application.StartupPath in Java

    The property "user.dir" is User's current working directory which is not in anyway the application path. Simply because there are no applications in Java, there are classes and jar files (Still classes but the path is not usable) for example if you create a class called "Test" and tried running it from another location in the Command Prompt the user.dir property is that location you are at when running the class. If this is not clear, lets say Test.class is in C:\Test while the command prompt current dir is C:\Windows. You can run Test from Windows if you add it to the classpath "java -cp C:\Test Test and the user.dir property will return C:\Windows. Try it
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width