Changing directory in java

what is the best possible way to change the directory through JAVA , on all Operating system , i have used "cd\"
but that is not working on other operating system, i also used System.setProperty("user.dir"); but that also isn't much useful
Regards
Edited by: mjmjava on Mar 8, 2013 3:39 AM

This seems to be the essentially the same question as your earlier post from today:
extracting the content of jar files into another folder
Shouldn't you just continue your inquiry in that thread? After all it is also about maneuvering around among various filesystem folders.

Similar Messages

  • How you change directory in Java

    Can someone tell me how to change directory in java ?
    Sample code would be much appreciated.
    Thanks in advance.

    Maybe you could explain why you think you need to change the directory. Then a solution to your actual problem might appear.

  • Change Directory in Java

    Hello,
    It seems there's a method of chdir ( ) to change the current directory in Java, but didnot work for me. Is there any better way to get around it? I mean, is it possible to change directory in run-time? if I put an argument on the command line for the user to enter, would it be possible, as long as the user has that permission?
    Thanks!

    Generally, this is not a good thing. It seldom accomplishes what you want .
    See this search list
    http://www.google.com/search?q=change+java+directory+site:forum.java.sun.com

  • Any other ways to change directory in Java Application??

    As Runtime.getRuntime().exec("cd ..") won't work in Java
    application, are there no other ways to change the current directory.
    Let's say the current directory is C:\test, and you run Test1.class
    C:\test\java Test1
    In Test1.java, you try to change the current directory to C:\helloworld.
    Is it possible???

    y do you want to chnge the current dir???
    if you want to access files then u can do that from ur current directory. simply create a file object using the absolute file path to the file
    for example if u r thinking of writing to a file located in c:\file and ur program is currently in c:\myProgram then u just have to create a file object
    file f = new file("c:\\file");
    then create ur input or ouput streams using this file object and you can do wat u want with it.
    even if you dont want to read or write to a file im sure you can use the absolute path to do wat you want without changing the current working dir.

  • Changing directory at command prompt

    when I try to change the directory to java at command prompt line it says invalid file name. I have check the path and it is fine. What is the problem?

    What operating system?
    If Windows, and the path contains any spaces, enclose the path within double quotes. eg.
    c:\> cd "C:\Program Files\Java\1.4.0"
    Bhav

  • Creating directory in  java

    HI all
    I need to create a directory in java.I need to check whether directory is present in c:/home if its not presend then i need to create one as
    .temp
    how do i that ?
    Thanks all for all the help.

    hello all thanks for all the help
    this is wat i did
    private static String k_localBaseDir;
    public static String getLocalBaseDir() {
                    if (k_localBaseDir == null) {
                    String home = System.getProperty("user.home");
                    k_localBaseDir = home + File.separator + ".temp";
                        } // if not set
            return k_localBaseDir;
        } Here in this method i get the local directory path ,this returns
    c:/w2/.temp
    but th eproblem is .temp directory is not created and it justs send the path thru k_localBaseDir.
    Since they have already defined this method as static i cant change this one .
    before returning the path i need to make sure that in that path .temp is created if its not .
    ane help pls

  • How do I change directory?

    How do I change directory? I mean something like "cd .."
    Thanks
    H.

    //Author: Richard Focke :)
    import java.io.*;
    class RuntimeExec{
         private static boolean quit;
         public static void main(String[]args)throws IOException{
              if(args.length<1){
                   System.out.println("Type in program to run");
                   System.exit(1);
              quit = false;
              Runtime run = Runtime.getRuntime();
              Process newProcess = run.exec(args[0]);
              if(newProcess!=null){
                   BufferedReader  br = new BufferedReader(new InputStreamReader(newProcess.getInputStream()));
                   PrintWriter os = new PrintWriter(newProcess.getOutputStream());
                   BufferedReader  be = new BufferedReader(new InputStreamReader(newProcess.getErrorStream()));
                   if(br!=null)(new ReadThread(br)).start();
                   if(os!=null)(new WriteThread(os)).start();
                   if(be!=null)(new ErrorThread(be)).start();
                   try{
                        newProcess.waitFor();
                   }catch(InterruptedException ie){}
              }else
                   System.out.println("Error creating process");
              newProcess.destroy();
              quit = true;
              System.out.println("Done!");
              System.exit(0);     
         private static class ReadThread extends Thread{
              private BufferedReader is;
              public ReadThread(BufferedReader is){
                   this.is = is;
              public void run(){
                   String s;
                   while(!quit){
                        try{
                             s=is.readLine();
                             if(s!=null)
                             System.out.println(s);
                        }catch(IOException e){}
         private static class WriteThread extends Thread{
              private PrintWriter br;
              private BufferedReader ss;
              public WriteThread(PrintWriter br){
                   this.br = br;
                   ss = new BufferedReader(new InputStreamReader(System.in));
              public void run(){
                   String s;
                   while(!quit){
                        try{
                             s=ss.readLine();
                             if(s!=null)
                             br.println(s);
                        }catch(IOException e){}
         private static class ErrorThread extends Thread{
              private BufferedReader br;
              public ErrorThread(BufferedReader br){
                   this.br = br;
              public void run(){
                   while(!quit){
                        String s;
                        try{
                             s=br.readLine();
                             if(s!=null)
                             System.err.println(s);
                        }catch(IOException e){}
    }

  • Change directory ?

    Hi,
    in the java.io package I can't find an API to get and change, resp.
    the current working directory. Guess I'm too blind ....
    Can anybody help, please.
    Klaus

    Hi,
    in the meantime I've found a one-year old thread with
    a related topic:
    http://forums.java.sun.com/thread.jsp?forum=54&thread=101876
    However, the last reply to this thread asks the same question
    I have...
    "Is it the case that there is no equivalent to "change current
    working directory" in Java?"
    Furthermore, I tried setProperty on the system property user.dir.
    But this simply sets a string in a hash and does not call the
    operating system at all.
    Any suggestions?
    Have fun,
    Klaus

  • Issue in Oracle 11g Database Change Notification  for Java application

    Hi,
    I am trying to use Oracle's Database Change Notification in Java application.
    I followed the sample application (+DBChangeNotification.java+ , Example 29-2), provided in the following link:
    +[http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/dbmgmnt.htm#CHDEJECF]+
    I am able to see that the Registration of the SQL query is successful.
    But, when I do changes to the table registered, notifications are not received in the Listener class (+DCNDemoListener.java+).
    Ideally, the method DCNDemoListener.onDatabaseChangeNotification() should be invoked on any insert/update to the registered table. But this method is not getting invoked.
    The execution has stopped in the following line of DBChangeNotification.java Class.
    this.wait();
    +==> The application was WAITing indefinitely in this line, as the NOTIFY() from DCNDemoListener.java was not executed.+
    I am using VPN to connect to Oracel server. Remote Oracle Server is protected my firewall. Is this the reason for not sending the notifications from Oracle server?
    The version of software used are given below:
    Oracle Client - Oracle 11.1.0
    JDK - 1.6
    Oracle JDBC Driver - ojdbc6.jar
    Can someone help me to resolve this issue?
    Thanks in Advance.
    Regards
    Sam
    Edited by: Ponsu on Apr 7, 2011 10:41 PM

    Hi,
    I am having similar issue. Where you able to resolve it.
    I am also using the same example you were using.
    I am using the following version.
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Compatibility: 11.2.0.0.0
    I do not see any notification coming back from the DB.
    Appreciate your help.
    Thanks & regards,
    Ebe

  • Compiler ignores changes in a java class

    Hi,
    I made changes to the java class code, compiles correctly and not execute this new java code. The new code is ignored for the jdeveloper. I tried with several version like jdk1.4.2_06, jdk1.4.2_12,jdk1.4.2_13,jdk1.4.2_17. I need to work with 1.4.2.
    Thanks in advance.

    Hi,
    too many missing information make it hard to give any useful answer to this
    - which version of JDeveloper
    - what is the java code you compile
    - in which context do you execute the code ?
    Frank

  • How to change directory in Terminal (ex. cd System HD)

    hi
    how to change directory in Terminal (ex. cd System HD)
    i wrote cd system hd, which did not work. Terminal understood it as cd system.
    is there some character to write a "space" between words?
    thanks

    You need to escape the spaces with a leading backslash or the shell will give you unexpected results.
    For example to cd to "folder with spaces"
    cd folder\ with\ spaces/
    Also, the bash tab-auto-complete is your friend. Type a character or two and then tab, you'll get the idea when you see the result. If there is more than one possible completion, then hit tab a couple of times quickly and you'll get a list of all of the options.
    hth

  • 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.

  • FTP Adapter Unable to change directory 'inputDir'

    Hi all. I'm trying to put the file into BPEL Process, transform and put it to the output directory like in tutorial 129.FTPAdapter FTPDebatching. But I've got this message:
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
    <part name="code">
    <code>550</code>
    </part>
    <part name="summary">
    <summary>file:/C:/OraHome_1/integration/orabpel/domains/default/tmp/.bpel_FTPDebatch0ing_1.0.jar/FTPDebatchingOutput.wsdl
    [ Put_File_ptt::Put_File(po) ] - WSIF JCA Execute of operation 'Put_File' failed due to: Error changing directory in the host.
    Change working directory to /outputDir in the server failed. ;
    nested exception is: ORABPEL-11431 Error changing directory in the host.
    Change working directory to /outputDir in the server failed.
    Check the error stack and fix the cause of the error.
    Contact oracle support if error is not fixable.</summary>
    </part>
    <part name="detail">
    <detail>550 /outputDir: The system cannot find the file specified.</detail>
    </part>
    </bindingFault>
    What am i must to do?

    Hi Varun,
    Review of the ftp protocol specification
    http://www.w3.org/Protocols/rfc959/
    http://www.w3.org/Protocols/rfc959/5_Declarative.html
    shows that LIST command
    LIST
    125, 150
    226, 250
    425, 426, 451
    450
    500, 501, 502, 421, 530
    does not have 550 code among the codes which are supposed to be returned by ftp server in response
    to ls command. So, it looks like the ftp server running on AIX platofrm violates the ftp protocol specification.
    As a result bpel ftp adapter returns an error and the process goes off-line.
    Solution:
    Apply patch 4508850.
    If for any reason the official patch does not work, then apply the patch manually using the following steps:
    1. Stop OC4J_BPEL
    2. Create the following directories:
    $O_H\integration\orabpel\system\classes\oracle\tip\adapter\file\inbound
    $O_H\integration\orabpel\system\classes\oracle\tip\adapter\ftp\inbound
    3. Copy the following files
    FileSource.class, PollWork.class, FTPSource.class
    from the patch to
    $O_H\integration\orabpel\system\classes\oracle\tip\adapter\file\inbound\FileSource.class
    $O_H\integration\orabpel\system\classes\oracle\tip\adapter\file\inbound\PollWork.class
    $O_H\integration\orabpel\system\classes\oracle\tip\adapter\ftp\inbound\FTPSource.class
    4. Restart OC4J_BPEL
    Cheers,
    Anirudh Pucha

  • How to get Operating systems Install Directory in Java

    Hey Friends
    I have a problem of getting to know Operating System Install directory in java for my application requriment.Can any body tell me how to know this or send me snippet of code
    THANKS

    Thanks for ur reply but i need to know the Operating System Install directory like c:\Windows & not the jre install directory.Your solution gives the jre installation dir.
    Any suggestions ?
    Thanks & Regards

  • Show Unix home directory in Java code

    Does anyone know how to show Unix home directory in java?
    Thanks a lot,

    With that in mind, I must add that the [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperty(java.lang.String)]System.getProperty() method will be handy.

Maybe you are looking for