How can I locate the 'Windows system path' with in java?

Hi,
Is it possible to locate the System path (usu x:\winnt\system32\) of the OS at run time? What classes and methods should I use?
Thanks in advance

You can't from pure java, that's a windows specific value that's stored in the registry. Sorry, you can get anything that's in the System.getPropeties() there are many usefule values in there like the user's home dir and the java runtime version and java home, but not the C:\winnt directory as a value. Sorry.

Similar Messages

  • How can I Locate the correct filepath in a jsp page?

    In http://localhost:8080/myweb/a.jsp, I will call a java bean file which is locate in http://localhost:8080/myweb/WEB-INF/classes/haha/DBConnection.class. This java file requires to read an external file which locates in http://localhost:8080/myweb/WEB-INF/classes/haha/db.txt
    My question is how can I get the correct filepath in this environment?
    inputStream = new BufferedReader(new FileReader(????????));
    Only this will work
    inputStream = new BufferedReader(new FileReader("D:\Program Files\Apache Software Foundation\Tomcat 5.5\db.txt"));
    But no one will place the file here, and it is impossible to do this when upload to 3rd party hosting.
    Any suggestion? thx.

    Thx all, in a jsp page, calling this method is fine.
    ServletContext s = getServletContext();
    String a = s.getRealPath("/");
    In a Servlet file, below method is ready to use:
    String b = getServletConfig().getServletContext().getRealPath("/");
    My problem is, I have a jsp page, which initialize a java bean , this java file is responsible for Database Connection, which will read the external text file to get the login, password and database name. So I won't need to recompile this file every time when I place in different platform with different configuration. I only need to edit the text file is ok.
    But How can I get the absolute file path when that jsp page initialize that java bean file? Below is my error, any suggestions are thx.
    package sql;
    import java.sql.*;
    import java.util.ArrayList;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DBConnection extends HttpServlet{
    public String sql = null;
    public Connection con = null;
    public Statement statement = null;
    public ResultSet rs = null;
    private BufferedReader inputStream = null;
    private static ArrayList<String> arr = new ArrayList<String>();
      public DBConnection(){
        String fs = System.getProperty("file.separator");
        ServletContext s = getServletContext();
        String realpath = s.getRealPath("/");
        String filepath = realpath + "WEB-INF"+fs+"Properties"+fs+"db.txt";
        try{
          inputStream = new BufferedReader(new FileReader(filepath));
          String l;
          while ((l = inputStream.readLine()) != null) {
            arr.add(l);
          Class.forName("com.mysql.jdbc.Driver");
          this.con = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+arr.get(0)+"?user=" +arr.get(1)+ "&password="+arr.get(2)+"&useUnicode=true&characterEncoding=utf-8");
          this.statement = this.con.createStatement();
        }catch (Exception e){
          System.err.println(e.getMessage());
        }finally{
    }java.lang.NullPointerException
         javax.servlet.GenericServlet.getServletContext(GenericServlet.java:159)
         sql.DBConnection.<init>(DBConnection.java:20)
         html.ShowCategory.<init>(ShowCategory.java:17)
         org.apache.jsp.left_jsp._jspService(left_jsp.java:66)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • How can i locate the resource file in the weblogic?

    hello
    in struts, i can leave some parameter in a resource file (such as "Application.properties")outside of my code,and get them in the "Action" class by the "getResource" method.
    in my data access tier,i still want to use such a machanism but i can't use the "getResource()" method,for example,there is a ConnectionPool class,i want to read some parameters from a resource file ("param.properties") that is under the same directory as the ConnectionPool class,the following is the code snippet:
    public static void init(DataSource ds){
    myself=new ConnectionPool(ds);
    java.util.Properties prop=new java.util.Properties();
    try{
    java.io.FileInputStream fin=new java.io.FileInputStream("./param.properties");
    prop.load(fin);
    }catch(Exception e){
    e.printStackTrace();
    System.out.println(prop.get("help.create"));
    the "ConnectionPool" class is in the "com.jhtop.task.forum.db.util" package,the "param.properties" is in the same package (com.jhtop.task.forum.db.util),
    but when i execute the program,it tell me that it can't find the file.if i use the absolute path,it works.
    i wonder how can i locate the file path in the weblogic,or what's my current path,or how may i setup my work directory?
    in tomcat,my current directory is bin directory,how about weblogic?
    who can help me?thank you!

    My english is bad and I'm not sure I've well understood your problem.
    How have you created your file ?
    Why do you put it in such a directory and not an other ?

  • How can i get the document full path in S_TieDocument?

    I create a new S_TieDocument and override 2 methods:
    extendedPreInsert and extendedPostInsert
    how can i get the document full path in these 2 methods?
    (e.g. if i use the system user to upload a new file named 'test.file' in system root path /home/system, and i want to get the document full path '/home/system/test.file', how to get it?
    anybody know it, pls tell me, thanks a lot.
    java source is as below
    package oracle.ifs.server;
    import oracle.ifs.beans.Document;
    import oracle.ifs.beans.DocumentDefinition;
    import oracle.ifs.beans.LibraryObjectDefinition;
    import oracle.ifs.beans.LibrarySession;
    import oracle.ifs.beans.PublicObject;
    import oracle.ifs.common.AttributeValue;
    import oracle.ifs.common.IfsException;
    import oracle.ord.itech.cmsdk.ws.view.EmbeddedCMSDKWebServicesWSStub;
    public class S_TieDocument extends S_Document
    public S_TieDocument(S_LibrarySession session, S_LibraryObjectData data)
    throws IfsException
    super(session, data);
    public S_TieDocument(S_LibrarySession session, java.lang.Long classID)
    throws IfsException
    super(session, classID);
    // Overrides
    public void extendedPreInsert(OperationState opState,
    S_LibraryObjectDefinition def)
    throws IfsException
    // Always call super
    super.extendedPreInsert(opState, def);
    // Get the LibrarySession
    S_LibrarySession session = getSession();
    def.setUserSetAttribute("CUSTOMATTRIBUTE",
    AttributeValue.newAttributeValue(""));
    //how can i get the document file full path here?
    public void extendedPostInsert(OperationState opState,
    S_LibraryObjectDefinition def)
    throws IfsException
    // Get the LibrarySession
    S_LibrarySession session = getSession();
    //how can i get the document file full path here?
    }

    In the new version of Numbers this option is not available.  You will have to type the file name into the header yourself.  You can post feedback to Apple using the menu item "Numbers > Provide Numbers Feedback"
    or use Numbers2.3 which should be in the folder "/Applications/iWork '09" if you previously had it installed

  • How can i locate the properties files within a ejb container?

    when i develop servlet+javabean structure application,in order to imploement decoupling,i
    would like to write the config information in the properties files(key-value pair),in
    servlet,i use "getResourceAsStream(String relativePath)" method to retrieve the
    configuration information from the properties files(i even write the SQL clause
    in the files),it alwsys works well.
    now,i want to implement such function within the ejb container,that is to read
    a properties file from session bean,but i don't know how can i locate the file
    within the ejb container by using relative path,i wonder if there is the same
    method within ejb container as "getResourceAsStream(.......)" method within servlet
    container?
    thanks for any helps!
    the code snippet is appreciated!

    In general, you should look at using environment entries (variables) in the
    deployment descriptors (both the war and EJB jar rather than properties
    files for configuring J2EE applications. The reasons for this are many:
    1. This is the official way to do it according to the spec. Properties
    files are the J2SE way of doing things
    2. As you note, that it's not obvious how you would (legally) read a
    properties file inside an EJB.
    3. It's consistent between the web and EJB part of your code
    4. the weblogic console and tools have good capabilities to edit these
    fields.
    Kent
    "zhebincong" <[email protected]> wrote in message
    news:[email protected]..
    >
    when i develop servlet+javabean structure application,in order toimploement decoupling,i
    would like to write the config information in the propertiesfiles(key-value pair),in
    servlet,i use "getResourceAsStream(String relativePath)" method toretrieve the
    configuration information from the properties files(i even write the SQLclause
    in the files),it alwsys works well.
    now,i want to implement such function within the ejb container,that is toread
    a properties file from session bean,but i don't know how can i locate thefile
    within the ejb container by using relative path,i wonder if there is thesame
    method within ejb container as "getResourceAsStream(.......)" methodwithin servlet
    container?
    thanks for any helps!
    the code snippet is appreciated!

  • How can I locate the file /Library/Keychains/FileVaultMaster.cer to reset my master password? Thanks!

    How can I locate the file /Library/Keychains/FileVaultMaster.cer to reset my master password? Thanks!

    The files that weren't inside the media folder on the original machine need to be copied over to exactly the same paths as they had on the source machine. See this thread for an ongoing discussion of a similar problem. See also this post on migrating the iTunes library.
    tt2

  • How can I locate the original .CR2 /  Raw file from Photos in finder?

    How can I locate the original .CR2 /  RAW file from Photos in the finder window? I would like to know a easier way to open my files and use them in Photoshop than having to go to the Pictures folder, right clicking "show packaged contents", and manually searching for my CR2's / RAW's. It is also ridiculous to have to export the RAW file to my desktop, and then take it into Photoshop or another photo editing program.  I was able to do this in iPhoto and find I cannot do so in Photos. Please help? Can you please consider adding a right click function that says "Show Original file in Finder". That would make it so much easier and better for those of us who want a simple way to access the original files and use them in other editing programs. At least with iPhoto you could go to the top menu / preferences and find your items.

    http://www.apple.com/feedback/macosx.html is the place for feature requests and feedback
    Rather than use the 'Show package Contents route, the supported and safer way is to export the unmodfied original.

  • How can I open the windows file directory in "WHEN-BUTTON-PRESSED" trigger

    Dear All,
    How can I open the windows file directory in “WHEN-BUTTON-PRESSED” trigger?

    Blessan Joseph,
    The solution is dependent on your Forms version and if your applications is traditional Client/Server (CS) (Forms 6i and lower) or web deployed (Forms 6i and higher). For CS, you would use the Get_File_Name() built-in as Faa demonstrated. For Web, you will need to use the WebUtil library function Client_Get_File_Name() as Sarah (OGIR) demonstrated. Both of these functions will return the full path to a file. Note: WebUtil is an external library so it requires you to perform some configuration on your developer client as well as on the Application Server. WebUtil is included with Forms 9i and higher, but you must download it for Forms 6i.
    My requirement is user should able to select windows directory for the output.Do you really need to allow the user to write to a file in the Windows directory? This is very dangerous and you should not allow users or programs to write to the Windows directory. Users should only be able to write files to "User" directories (\My Documents\<Directory name>).
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Teststand 1.03 - How can I get the sequence file path into an expression?

    The sequence file will be located at different locations on different computers. I need the base address of the sequence file to get to the correct limits file. How can I get the sequence file path into a string-local expression.
    Thanks

    As Ray described, the FindFile expression function and TS API method will seach all TS search directories and return to you the path of your file, assuming the file is located in the search directories.
    If you just want the path of a TS file that you have a reference to then there is a faster, easier method. You can use the Path property of the PropertyObjectFile class. In the attached example I use an AcitiveX Automation adapter step to call Path on the property RunState.SequenceFile. This returns the path to the current executing sequence file. Note that if you have not yet saved the sequence file then the path will be empty. In a subsequence step I strip off the file name leaving the root path of the file.
    Attachments:
    GetSeqFilePath.seq ‏22 KB

  • I have one apple ID for both my Iphone 4S and Ipad. My Ipad was stolen from me and when I checked the iCloud, it can only locate the Iphone 4S. How can I locate the Ipad device?

    I have one apple ID for both my Iphone 4S and Ipad. My Ipad was stolen from me and when I checked the iCloud, it can only locate the Iphone 4S. How can I locate the Ipad device?

    Welcome to the Apple Community.
    You can only locate your device when it is logged into iCloud and 'Find My Phone' is enabled, additionally the device will need to be switched on and connected to a wifi or cellular network.
    Unfortunately, you cannot activate iCloud or 'Find My Phone' remotely.

  • How can I change the window size of iTunes?  Used to be easy before installing Mavericks.

    How can I change the window size of iTunes on my iMac?  Used to be easy before installing Mavericks.

    If you want to make the itunes tab so you can see the dock
    you press the
    esc
    button if your in full screen mode
    if you want to get into full screen mode you press the arrows facing away from eachother in the top right corner
    there is another way to get to the normal tab if your in full screen
    make the curser go right up to the top of the screen and it will show the apple tab
    it will have two arrows facing together highlited in blue
    if u tap that it will take you to the normal tab

  • HT5639 i use boot camp to install windows 8.1 but in the middle of the installation it is stop,how can i install the windows again?

    i use boot camp to install windows 8.1on my mac but in the middle of the installation it is stop,how can i install the windows again?
    why it`s stop?

    What is your exact machine and what's the error

  • My Webpage screen is always minimized. How can I enlarge the window?

    My Webpage window is smaller then my screen the window is at about 10 inches instead of the whole scren . How can I enlarge the window (webpage) ? it is so annoying to work with this screen.
    Any help would be greatly apperciated.
    Thank you

    The first place to start may be to check Activity Monitor. Look at the Disk Usage tab and the CPU tab and see if any one or two things seem to be dominating that activity. Especially see if it's some 3rd party app or background process.

  • I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    I have downloaded a music file through a downloader . But the file is not found in the captured in music player . How can I locate the physical location and move the file . I cannot do via itunes also .

    Exactly what do you mean by a 'downloader'?
    Thanks
    Pete

  • Help with Adobe.premiere.elements12. Please It would appear under the organizer tab that the photos are organised in the lowest folder in the folder structure within Windows Explorer.  How can I use the Windows Explorer structure to organise the photos wi

    Help with Adobe.premiere.elements12. Please
    It would appear under the organizer tab that the photos are organised in the lowest folder in the folder structure within Windows Explorer.  How can I use the Windows Explorer structure to organise the photos within Elements.

    In a situation such as yours, I tend to consolidate items into folders so I have folders of nice workable numbers of images, somewhere between 20 and 200 images. Now, whatever, once you've imported, do your moving within LR, not the OS! I will select all in a folder and drag into a folder a level or two or three above, and then delete the newly empty subfolders. I hope this helps a bit!
    Once you've reached just new Imports of camera output, you'll be flying along.

Maybe you are looking for

  • Conditional legend in DVT graph

    Hi, Is there a way to somehow conditionally show/hide the legend tag of a DVT based on some runtime values? <dvt:barGraph id="barGraph1" >   <dvt:legendArea automaticPlacement="AP_NEVER" rendered="false"/> </dvt:barGraph>I checked out the rendered pr

  • Unrecognized Batter

    It appears my battery is not recognized by the computer. In the battery pull down menu, I see an 'X' inside the battery icon, and when I click on the menu, I see a greyed out message 'No batteries available.' If I unplug the AC, the computer shuts do

  • USB to micro USB charging question

    I was about to buy an in-car charger for my 9630. Since i have an in-car usb port, I;m wondering if I can just get a USB to microUSB cable, connect the phone to the car, and get a charge. Thanks, jwp48

  • I have just updated my iphone4 and now I can't download any apps, its saying I need a valid US address?? any how much appreciated.

    Any helpful suggestions to explain why I can't download any apps will be appreciated. Its saying I need a valid US address I live in Australia? dont know why its asking that.

  • Class def error?

    hi I am using NWDS 7.0 and EP 6.0 .While deploying one of my application i am getting the error: java.lang.NoClassDefFoundError: com/sap/tc/webdynpro/clientserver/uielib/standard/api/IWDAbstractTableColumn I want to solve this problem by using some d