Finding the current path

Hey all,
what is the shortest way to get the current directory?

You can also call System.getProperty("user.dir"), which will return the user's current working directory as a String. Using "user.home" as the method parameter will give you the user's home directory. So if you want/need either of those directories, there's a simple 1-line way to obtain the values.
-dSn

Similar Messages

  • Find the installation Path of the current running VM on Windows

    Hello,
    I have a java class started by webstart.
    In this class I would like to find the absolute path of the current running vm? This is important to me because I need to start an exe file (using ProcessBuilder) and hand it the path of the java VM,
    For example I could try something like this:
    private static File findJDK() throws Exception {
    String s = System.getProperty("java.home");
    File myJRE = new File(s);
    if (new File(myJRE, "bin/javac.exe").isFile()) {
    return myJRE;
    File parent = myJRE.getParentFile();
    if (new File(parent, "bin/javac.exe").isFile()) {
    return parent;
    for (String pathel : System.getenv("PATH").split(File.pathSeparator)) {
    File bindir = new File(pathel);
    if (new File(bindir, "javac.exe").isFile()) {
    return bindir.getParentFile();
    return myJRE;
    But I would like the above code to be more fool proof!
    For example the "java.home" could be wrongly set.
    Since java is allready running I would have hopped that I could query the Runtime. But there seems to be no method providing the running java VM path?
    I also tried looking at the jnlp services API but no luck.
    I would be also interested find the lastest java VM on the client Windows machine....
    Many greetings
    john

    http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getProperties()
    bye
    TPD

  • How to get the current path of my application in java ?

    how to get the current path of my application in java ?
    thanks

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

  • How to get the current path/directory

    Hey,
    I was wondering how to figure out the current path or directory where my Application is running (stored) in! I know there is a statement like getCodebase() for Applets to get the actual path, but I couldn't find anything similar for regular Applications. I think I can not just use a absolute path, since it might run on different os with different file seperator (like /root or c:\). Any help is welcome!
    Thank you very much,
    Marc

    Try this ...
            System.out.println("current directory = " + System.getProperty("user.dir"));
    [/code}                                                                                                                                                                                                                               

  • How to find the menu path ?

    Hi all,
    I have one doubt how do we find out the correct menupath if we know the t-code ?
    for example, SE11 -DDIC
    we can also obtain the same DDIC screen via menupath from SAP main screen.
    if I know only t-code.how can i find out the menupath ?
    thnks and rgds,
    raghul

    Hi Raghul,
      You can go to the transaction search_sap_menu
    for finding the menu path.
    check this link:
    http://www.sap-basis-abap.com/sapgeneral/system-path-and-transaction-code-mapping.htm
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • Issue in finding the current row

    I am rendering rows of a VO using an iterator component. One of the component I am rendering is a declarative component created by me.
    In this component there is a clickable link on which i can write any method to achieve desired functionality.
    Since, iterator is used so the current row is set to the last row. Now on clicking the link in the declarative component i need to do some operation based on the current row (pk of that row). So, how to find the current row id?
    Note: If it would be a simple adf component like a commandLink i could have inserted a setServerListener inside it and could have put the id in to requestScope to access it. But as this is the declarative component in which i cannot create a serverListener so I am looking for some other solution.

    Hi john,
    My table have the selection listener.
    Thanks in advance

  • How to find the absolute path of file  which store in KM foler ?

    Hello everyone:
         We want to develop an ABAP program which can write files into KM folder directly.
         So I need to find the absolute path of file which store in KM folder first, then we can consider the develop solution.
         Is this issue possbile that an ABAP  program write files into KM folder  directly ?
         Is there anybody had done this job ?
    Best Regards,
    Jianguo Chen

    Hi,
    http://forum.java.sun.com/thread.jsp?forum=34&thread=36
    612The methods in the above topic seem to be available when use a DOM parser..

  • Need Help in finding the Menu Path's for the below topics

    Hi,
    Where can i get the menu paths for the below topics in SAP syste. I have searched in the system,But couldnot find the Menu Path's for the below topics.Kindly help me in finding the configuration Path for the below...
    1)Public tendering process
    2)Grants Management
    3)Tax & Revenue management
    4)Public sector accounting --> Budget formulation, preparation, execution & Monitoring.
    Thanks
    Rajitha M

    Hi,
    Check for the relevant path in IMG in Public Sector Management.  The prerequisites being configuration of Financial accounting
    sub modules.
    Best Regards,
    Sadashivan

  • Finding the exact path of a file using a Java program

    Can anyone tell me how to find the exact path of a file which is saved in a directory other than the one in which the main file is saved? I know there is a class called File which has many methods like isAbsolutePath() and isPath() but they return the path in which the main class is located

    actually i m trying to write a program which will
    take a name of a file or a directory from the console
    and it should give the entire path of that file or
    directory and this file need not be stored in the
    path of the main class.....It can be stored in any
    drives of my PC....Ok, then the console input needs to be an absolute path or a path relative to some given directory (usually the one from which the application is started). Java cannot magically guess absolute paths if you just provide a file name. E.g. if I'd use your program and would provide as input "build.xml", how should the program know which file by that name I mean (there are lots of build.xml files in different locations on my machine)?

  • Finding the context path or docBase in a backing bean - Howto

    How should I go about finding the context path or docBase in a backing bean?
    Is there anyway to get this from glassfish or jsf? GlassFish proudly displayed it on the Application Server > Applications > Web Applications > page. It puts it there with an EL for example:
    ${com.sun.aas.instanceRoot}/applications/j2ee-modules/jsf-witaCan and/or should I try to use it in a backing bean? i.e. can I rely on it to stay defined?
    Or should I make a property which I can set for my backing work?

    Is this what you want?
    FacesContext.getCurrentInstance().getExternalContext().getContext()

  • Finding the shortest path

    Hey guys,
    Im working on a solution to this problem below is a program to allow a user to draw straight line paths. What i'd like to do is allow the user to select two points on the path he has drawn and find the shortest path among all the interesecting lines.....im going crazy thinking of a solution for this.....im thinking bout steeping down a notch and just try to find just any path first.
    Will really appreciate any help.
    Thnx in advance,
    Vikhyat
    import java.applet.*;*
    *import java.awt.*;
    import java.awt.event.*;*
    *import javax.swing.*;
    import java.awt.geom.*;
    public class Lab11 extends Applet implements MouseListener, MouseMotionListener {
    int x0, y0, x1, y1;
    int mouseRelease=0;
    GeneralPath path = new GeneralPath();
    public Lab11()
    addMouseListener(this);
    addMouseMotionListener(this);
    public void mouseDragged(MouseEvent e)
    x1 = e.getX();
    y1 = e.getY();
    repaint();
    public void mouseMoved(MouseEvent e) { }
    public void mouseClicked(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited (MouseEvent e) { }
    public void mousePressed(MouseEvent e) {
    x0 = e.getX();
    y0 = e.getY();
    System.out.println("Mouse pressed at: (" +
    x0 + ", " + y0 + ")" );
    public void mouseReleased(MouseEvent e) {
    x1 = e.getX();
    y1 = e.getY();
    System.out.println("Mouse released at: (" +
    x1 + ", " + y1 + ")" );
    mouseRelease = 1;
    this.repaint();
    public void paint(Graphics g)
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    //just for show not concerned with saving paths
    if(mouseRelease==1)
    path.moveTo(x0,y0);
    path.lineTo(x1,y1);
    mouseRelease = 0;
    g2.setPaint(Color.RED);
    g2.draw(path);
    g.setColor(Color.BLACK);
    g.drawLine(x0, y0, x1, y1);
    public static void main(String[] argv)
    JFrame f = new JFrame("Test");
    f.getContentPane().add(new Lab11());
    f.setSize(600,600);
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }Pictorially this is what im trying to do:
    User draws a path like so and selects two points as shown in blue
    [http://i48.photobucket.com/albums/f236/theforrestgump/select.jpg]
    The program should then proceed to highlighting the shortest path
    [http://i48.photobucket.com/albums/f236/theforrestgump/sp.jpg]
    Edited by: cannonball on Apr 1, 2008 7:58 PM

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class ShortPath extends JPanel {
        Path2D.Double path;
        Path2D.Double shortPath = new Path2D.Double();
        Point p1 = new Point();
        Point p2 = new Point();
        final double PROXIMITY = 5.0;
        public ShortPath() {
            path = new Path2D.Double();
            path.moveTo(145,80);
            path.lineTo(125,170);
            path.lineTo(190,200);
            path.lineTo(240,340);
            path.lineTo(285,220);
            path.lineTo(145,80);
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.blue);
            g2.draw(path);
            g2.setPaint(Color.green);
            g2.setStroke(new BasicStroke(2f));
            g2.draw(shortPath);
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(p1.x-2, p1.y-2, 4, 4));
            g2.setPaint(Color.orange);
            g2.fill(new Ellipse2D.Double(p2.x-2, p2.y-2, 4, 4));
        private void findShortPath() {
            if(!isPointOnLine(p1) || !isPointOnLine(p2)) {
                System.out.println("a point is not on the path");
                return;
            double d1 = getDistanceToPoint(p1);
            double d2 = getDistanceToPoint(p2);
            double pathLength = getDistanceToPoint(new Point());
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end   = new Point2D.Double();
            if((d1 < d2 && d2 - d1 < pathLength - d2 + d1) ||
               (d1 > d2 && d1 - d2 > pathLength - d1 + d2)) {
                start.setLocation(p1);
                end.setLocation(p2);
            } else {
                start.setLocation(p2);
                end.setLocation(p1);
            generatePath(start, end);
        //                        145,80
        // leg distance = 92.2    125,170
        // leg distance = 71.6    190,200   163.8
        // leg distance = 148.7   240,340   312.5
        // leg distance = 128.2   285,220   440.7
        // leg distance = 198.0   145,80    638.7
        private double getDistanceToPoint(Point p) {
            PathIterator pit = path.getPathIterator(null);
            double[] coords = new double[2];
            double distance = 0;
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end = new Point2D.Double();
            Line2D.Double line = new Line2D.Double();
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                        start.setLocation(coords[0], coords[1]);
                        pit.next();
                        continue;
                    case PathIterator.SEG_LINETO:
                        end.setLocation(coords[0], coords[1]);
                line.setLine(start, end);
                boolean onLine = line.ptSegDist(p) < PROXIMITY;
                if(onLine) {  // point is on this line
                    distance += start.distance(p);
                    break;
                } else {
                    distance += start.distance(end);
                start.setLocation(end);
                pit.next();
            return distance;
        private void generatePath(Point2D.Double first, Point2D.Double second) {
            Point2D.Double p = new Point2D.Double(first.x, first.y);
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end = new Point2D.Double();
            Line2D.Double line = new Line2D.Double();
            boolean pathStarted = false;
            for(int j = 0; j < 2; j++) {
                PathIterator pit = path.getPathIterator(null);
                double[] coords = new double[2];
                while(!pit.isDone()) {
                    int type = pit.currentSegment(coords);
                    switch(type) {
                        case PathIterator.SEG_MOVETO:
                            start.setLocation(coords[0], coords[1]);
                            pit.next();
                            continue;
                        case PathIterator.SEG_LINETO:
                            end.setLocation(coords[0], coords[1]);
                            line.setLine(start, end);
                            boolean onLine = line.ptSegDist(p) < PROXIMITY;
                            if(onLine) {            // found point on line
                                Point2D.Double linePt = getClosestPoint(line, p);
                                Line2D.Double segment;
                                if(!pathStarted) {  // found first point
                                                    // both points on line
                                    if(line.ptSegDist(second) < PROXIMITY) {
                                        Point2D.Double secPt =
                                            getClosestPoint(line, second);
                                        segment = new Line2D.Double(linePt, secPt);
                                        shortPath.append(segment, false);
                                        return;
                                    } else {        // first point only
                                        segment = new Line2D.Double(linePt, end);
                                        shortPath.append(segment, false);
                                        p.setLocation(second);
                                        pathStarted = true;
                                } else {            // found second point
                                    segment = new Line2D.Double(start, linePt);
                                    shortPath.append(segment, false);
                                    return;
                            } else if(pathStarted) {
                                                    // add intermediate lines
                                Line2D.Double nextLine =
                                    new Line2D.Double(start, end);
                                shortPath.append(nextLine, false);
                    start.setLocation(end);
                    pit.next();
        private Point2D.Double getClosestPoint(Line2D.Double line,
                                               Point2D.Double p) {
            double minDist = Double.MAX_VALUE;
            Point2D.Double closePt = new Point2D.Double();
            double dy = line.getY2() - line.getY1();
            double dx = line.getX2() - line.getX1();
            double theta = Math.atan2(dy, dx);
            double length = line.getP2().distance(line.getP1());
            int limit = (int)(length+.05);
            for(int j = 0; j < limit; j++) {
                double x = line.getX1() + j*Math.cos(theta);
                double y = line.getY1() + j*Math.sin(theta);
                double distance = p.distance(x, y);
                if(distance < minDist) {
                    minDist = distance;
                    closePt.setLocation(x, y);
            return closePt;
        private boolean isPointOnLine(Point p) {
            Point2D.Double start = new Point2D.Double();
            Point2D.Double end = new Point2D.Double();
            Line2D.Double line = new Line2D.Double();
            PathIterator pit = path.getPathIterator(null);
            double[] coords = new double[2];
            while(!pit.isDone()) {
                int type = pit.currentSegment(coords);
                switch(type) {
                    case PathIterator.SEG_MOVETO:
                        start.setLocation(coords[0], coords[1]);
                        pit.next();
                        continue;
                    case PathIterator.SEG_LINETO:
                        end.setLocation(coords[0], coords[1]);
                        line.setLine(start, end);
                        if(line.ptSegDist(p) < PROXIMITY) {
                            return true;
                start.setLocation(end);
                pit.next();
            return false;
        public static void main(String[] args) {
            ShortPath test = new ShortPath();
            test.addMouseListener(test.ml);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
        private MouseListener ml = new MouseAdapter() {
            boolean oneSet = false;
            public void mousePressed(MouseEvent e) {
                Point p = e.getPoint();
                if(oneSet) {
                    p2 = p;
                    findShortPath();
                } else {
                    p1 = p;
                    shortPath.reset();
                oneSet = !oneSet;
                repaint();
    }

  • How to Find the Current Instance Id in Oracle 10g

    Hi,
    how to find the current instance id in oracle 10g studio,
    I have the below code :
    if (InstanceScreenFlow.processInstance.id.id.indexOf(text : ins.id) < 0) {
    /// do something
    it is saying that "'processInstance' is not a function"
    Thanks,
    Brijesh Kumar Singh.

    Why not just pass in the "id" predefined variable into your screenflow? Once you do that you'll be able to refer to it as "id.id" anywhere inside your screenflow.
    Dan

  • How to find the current SQL

    Dear All,
    My testing engineers are checking the application from front end, i have to find the current SQL (What SQL queries are used in the application) statements in the back end.
    Please let me know how to find the current executing SQL stements.
    Thanks in advance
    Mahi

    You need to join this query with one more table - v$sqlstats. There are many statistics in particular cpu_time, elapsed_time etc stored in that table for each sql statement.
    You can join v$sqlstats by sql_id until you have multiple child cursors for single statement.
    Or you can just join to v$sql and get statistics from there and in this latter case you include child_number column to distinguish child cursors from each other.
    Best Regards,
    Alex

  • Can I find the current tab in Terminal using applescript?

    Running a script from the shell by prepending
    #! /usr/bin/osascript
    as part of my .profile, can I find the "current" tab using Applescript. Most of the time, the "current" tab will not be visible, as the shell is being initialised, or re-initialised.
    I want to set the dircolors for my shell by determining the background color of the tab in which the shell is executing.

    Under the Window menu you can activate any of the palettes that you want. In your case the Field tab is under the Object palette

  • Standard report Programs to find the current status of workflows

    Hi Experts,
                       Are there any Standard report Programs to find the current status of workflows or workflows which are pending.
    Regards,
    Hari

    Go to SWI1 t-code
    Give the appropriate Status - Ready or Inprocess or Waiting
    Input the Task - either WF Template or Standard Task.
    Choose the time period and execute the report.
    Regards,
    PR.

Maybe you are looking for

  • Adobe Acrobat 8 - file updates not installing on Win 7 Professional

    How do I install MSP file updates to Adobe Acrobat after downloading them? I have just installed Acrobat 8.0 from the original installation CD on a new PC running Windows 7 Professional (64 bit) and have downloaded the update to 8.1.0 to begin with,

  • IDOC Number from payload in Alerts with out BPM

    Hi Everybody, I need to send the IDOC Number as Alert for the user. Is it possible to do with out BPM either by Alert Frame Work or CCMS? Is there any alternative way to capture the Idoc number and display for the erroneous messages? Helpful Answers

  • Imported mailboxes have internal Messages folders and I cannot drag-and-drop to them

    I have just been forced to upgrade to a new MB Pro due to liquid damage to my old Macbook Pro.  As I am now using Mountain Lion I have had all manner of reconfigure problems with importing the (undamaged) data from my old hard drive.. When I open Mai

  • I cannot open final cut X

    I cannot open final cut. I got a message saying my HD was full and I needed to delete files in order to continue, so I did but since then I have not been able to open Final cut x. All I get is the mac loading wheel. Any ideas why I can't open it?

  • Substituting G/L account

    Hello, i need to replace the G/L account for indirect costs when creating the invoice. The default account for indirect costs is defined in OBYC, say acct XXXXXXXX. Based on PO type, accounts AAAAAAAA or BBBBBBBB must be charged. I've used the substi