How to set my working directory?

Hy! This is my first post on this forum. I hope you can help me.
I need to save a file in an existing folder, inside my current working directory. I've tried to set the folder where I want to save my file as the working directory.This is what I tried to do:
try{
          System.setProperty("user.dir",myDirectoryName);
          PrintWriter file = new PrintWriter(new BufferedWriter(new FileWriter(jtp.getTitleAt(jtp.getSelectedIndex()))));
                              file.print(((JTextArea)jtp.getSelectedComponent()).getText());
file.close();          
}catch(IOException mes){
          System.out.println("Nu pot sa creez fisier");
But....is not working,because the file is created in the old working directory.
I thought that using a file chooser could help me,but the problem is that this saving is just an intermediate step in compiling the file,so the use of a FileChooser would not be appropiate.
Thank's.

Thank you,it helped me a lot.
I have now another problem: I want to run some 16 bits programs. Since there are some problems with that, I've created some 32 bit programs in C that run those 16 bit programs,and then I ran those programs from my Java program. The problem is that this approach works fine only for some programs,not for all. I'll put below the code I wrote(hope it won't be too much):
     try{//the launching programs runs tasm.exe program-works fine
          //          Process proc=Runtime.getRuntime().exec(args);
                    Process proc = new ProcessBuilder("launching","p0.asm"/*"p"+jtp.getSelectedIndex()+".asm"*/).start();
                    InputStream istr = proc.getInputStream();
     BufferedReader br = new BufferedReader(new InputStreamReader(istr));
     String str; // Temporary String variable
     while ((str = br.readLine()) != null) temp+=(str+"\n");
     try { proc.waitFor(); }
     catch (InterruptedException ee){
                         System.err.println("Process was interrupted");
//...link program runs tlink.exe program- the tlink.exe doesn't stops,altough it //works fine when it runs from the command line
     Process proc = new ProcessBuilder("link","p0").start();
The launching program is:
#include <shlobj.h>
#include <shlwapi.h>
int main(int argc, char* argv[])
     SHELLEXECUTEINFO ShExecInfo;
     ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb="open";
     ShExecInfo.lpFile="tasm.exe";
     ShExecInfo.lpParameters=argv[1];
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_MAXIMIZE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
     return 0;
The link program is:
#include <shlobj.h>
#include <shlwapi.h>
int main(int argc, char* argv[])
     SHELLEXECUTEINFO ShExecInfo;
     ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = NULL;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb="open";
     ShExecInfo.lpFile="tlink.exe";
     ShExecInfo.lpParameters=argv[1];
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_MAXIMIZE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
     return 0;
My question is: why does it work for tasm and doesn't work for tlink? The programs are pretty much the some,don't they?
Thanks again for youre help.

Similar Messages

  • How to set the working directory for reports in linux

    Hi All,
    Can you anyone help me to set the working directory for oracle application server 10g reports? I am using RHEL4 and AS10g. Actually i want to run my reports from my define
    working directory. How can I do this?
    Thanks in advance
    Arif

    Hi,
    your rep_srv.conf should look like something like
    +<?xml version = '1.0' encoding = 'ISO-8859-1'?>+
    +<!DOCTYPE server PUBLIC "-//Oracle Corp.//DTD Reports Server Configuration //EN" "file:D:\oracle\FRHome_1/reports/dtd/rwserverconf.dtd">+
    +<server version="10.1.2.0.2">+
    +<!--Please do not change the id for reports engine.-->+
    +<!--The class specifies below is subclass of _EngineClassImplBase and implements EngineInterface.-->+
    +<cache class="oracle.reports.cache.RWCache">+
    +<property name="cacheSize" value="50"/>+
    +<!--property name="cacheDir" value="your cache directory"-->+
    +<!--property name="maxCacheFileNumber" value="max number of cache files"-->+
    +<!--property name="ignoreParameters" value="parameter names to be ignored in constructing cache key, separated by comma ','"-->+
    +</cache>+
    +<engine id="rwEng" class="oracle.reports.engine.EngineImpl" initEngine="1" maxEngine="3" minEngine="0" engLife="50" maxIdle="30" callbackTimeOut="90000" jvmOptions="-Xmx512M -Xss512K">+
    +<!--property name="sourceDir" value="your reports source directory"/-->+
    +<!--property name="tempDir" value="your reports temp directory"/-->+
    +<!--property name="keepConnection" value="yes"/-->+
    +</engine>+
    +...+
    some more definitions
    +..+
    +<!--pluginParam name="proxy" type="file">proxyinfo.xml</pluginParam-->+
    +<pluginParam name="xmlpds" type="file">xmlpds.conf</pluginParam>+
    +<pluginParam name="jdbcpds" type="file">jdbcpds.conf</pluginParam>+
    +<pluginParam name="textpds" type="file">textpds.conf</pluginParam>+
    *<environment id="APP1">*
    *+<envVariable name="REPORTS_PATH" value="/application1/reports"/>+*
    *+</environment>+*
    *+<environment id="APP2">+*
    *+<envVariable name="REPORTS_PATH" value="/application2/reports"/>+*
    +</environment>+
    +</server>+
    The environment ids you can choose yourself and you have to put them in there yourself too (here I put two environments for two different applications "1" and "2").
    If you call a report from Forms, then you have to code something like
    ADD_PARAMETER(p_list,'ENVID',TEXT_PARAMETER,'APP1');
    Details depend on how you call your reports, my example is for using a parameter list and calling a report out of application1
    Hope that helps.
    Volker

  • How to set default working directory in iSQL*PLUS

    In regular SQL*Plus, one could set the properties attribute of the shortcut icon to a default working directory. Is there a way to set a default for iSQL so that you don't have to reset this each time you log on?

    The default path for the "Browse..." (Netscape) or
    "Choose" (Opera 6) button for loading scripts????
    This would be browser specific - even the button text
    is chosen by the browser. I've never tried to rig the
    initial path. Maybe it can be done with a shortcut
    to the browser executable?
    -- CJ

  • How to set the initial directory

    Using the FileChooser in JavaFX 2.0. How do you correctly set the initial directory?
    In Swing you would do the following:
    JFileChooser Choose = new JFileChooser();
    Choose.setCurrentDirectory(new File("."));But in JavaFX:
    Choose.setInitialDirectory(new File("."));does not work and causes JavaFX to bomb out when this code is triggered.
    Edited by: 863626 on 30-Oct-2011 05:30

    javafx.stage.FileChooser choose = newjavafx.stage.FileChooser();
    File d = new File(getClass().getResource(".").getFile());
    choose.setInitialDirectory(d);

  • Illustrator needs a Relative mode switch or ability to set a Working directory for each AI file!

    Hi guys,
    I thought I would post in here because I find I'm wanting this feature more and more over the past year.
    This can apply to most of Adobes application but it would be great to see some file management functionality built into the applications themselves. This could then be further expanded in Bridge/Cue to incorporate more applications into the working project but at the very least the application itself the ability to control its own root existence.
    On so many occasions I require Illustrators file linking feature to be relative and NOT absolute which it currently is. The only relative capability it has is if ALL the linked assets are in the same local directory as the AI file itself and this as everyone knows breaks the first rule of proper file management.
    Many of the projects I work on uses many AI files with sometimes over 50 linked in assets in a variety of different formats from a variety of different clients (locations). I cannot easily move this project folder around without the painful task of linking all the data again and this creates a massive issue.
    Ideally an approach similar to Autodesks Maya and Max where you can set project directories. This means all the Save As and other operations will default to that working directory for that file. All linked data will then use the projects working directory as its root and allow the project to move from location to location and not be affected.
    This would Im sure benefit many other designers who work on projects with large amounts of data that may not live always in the same spot. For us we work with so many different people during a production that mobility is a must and at the moment we are finding it very difficult.
    As always, thanks for reading.
    Cheers
    Nick.

    Hello,
    First command
    So what does the wiki meen by: "DEVPATH sets the physical device. You can determine this by executing the command
    readlink -f /sys/class/hwmon/hwmon-device/device | sed -e 's/^\/sys\///'"
    Physical device of what, and what output am I suppose to get: Nothing, a list with output on where the symlinks lead, something else... In my case I got no output, if that is right, I do not know - since I do not understand what the command do.
    Seccond comand
    DEVNAME: Sets the name of the device. Try:
    sed -e 's/[[:space:]=]/_/g' /sys/class/hwmon/hwmon-device/device/name
    Does it meen like this - If I during my pwmconfig used hwmon1 wich was coretemp, and hwmon2 wich was nct6775, I should do:
    sed -e 's/[[:space:]=]/_/g' /sys/class/hwmon/hwmon1-device/device/name coretemp
    sed -e 's/[[:space:]=]/_/g' /sys/class/hwmon/hwmon2-device/device/name nct6775
    And that will direct every occurrence of hwmon1 and hwmon2 to the correct sensor chip?
    Regards
    Martin
    Last edited by onslow77 (2015-01-23 21:46:04)

  • How to set the target directory from source filename using adaptor module.

    Hi,
    How im using a logical bypass scenario.I have to set the target directory using the sorce filename.There is no chance of using a Java UDF as my scenario does not have a Mapping(as it is a Bypass Scenario).The only option that i got is to use a Adaptor module.Can anyone help  me this.
    Thanks,
    Bhargav

    Hi,
    See this link,
    http://help.sap.com/saphelp_nw04/helpdata/en/e9/61e1407e858031e10000000a1550b0/content.htm
    hope it helps.
    Regards,
    Akshay Jamgaonkar.
    Reward points if find useful.

  • How to set Field "Work" to 0 using PSI

    Dear all,
    I'm creating Tasks in MS Project using PSI.
    This works fine.
    I've a request to set the "Work" Property of the Task to "0h".
    Maybe somebody of you know how to do this. I thought that the property
    TASK_WORK is for that but when I set this property to 0 there is no Action.
    Thanks
    bernhard

    Solved
    Set the Property ASSN_WORK to 0 in the Object AssignmentRow.
    BR
    Bernhard

  • How to set the deployment directory ?

    Hi all,
    I am using Sun One Studio 3.0 with iWS6.0.
    For every new application that I write, compile and execute,
    it is getting deployed to the same
    directory.
    Because Sun One Studio is always using the same directory,
    for every application I have
    to manually delete the deployment directory.
    Is there any way to set different deployment
    directory for every new application that I write ?
    If yes, how to do this ?
    Thanks
    Swap

    I dont have the product installed, so I cannot try it right now. But I think the context root is part of the directory name in which the application is deployed. By default the context root is empty. If you change that, your application would be deployed in a different directory. To change context root, right click on WEB-INF node, and select "Properties" from the menu.
    Alternatively, you could try changing the directory name by right-clicking on the web.xml node under WEB-INF. You should see an iWS tab on the property sheet, where you could enter a directory name.

  • How to set up Open Directory Users with local home folders?

    Hi folks,
    i set up a Mac mini Server with the services DNS, DHCP, AFP and OpenDirectory running. Everything is working fine so far but i want my OpenDirectory Users to have their home folders locally on the clients harddisk. My Leopard clients are already bound to the directory but everytime i try to login the login window is shaking even when i use the Directory Administrator account. What am i doing wrong?
    Thanks.

    (Did you read my other reply? You need to make it a portable account for the caching of login credentials.)
    With network homes and portable account enabled on a machine you always run from the locally stored homefolder on that machine.
    This homefolder syncs with the server network home folder for that account.
    If either of these folders get corrupt or unintentionally altered files (permission problems) somehow, there is risk of losing files, syncing problems and more (can take long time to sync at login/out, during even without corruption - I prefer gigabit cable to WiFi for this for obvious reasons).
    You at least need to monitor storage space in both places. You don't want either to fill up the disk (worse on server because several users can have their folders corrupted at the same time). Working quota settings / account is probably a good thing.
    And you probably need to decide what is synced : all folders or just some (and when / how often).
    You either do this form the server (you decide) or let the user have some say or a mix of these two.
    You might want to leave out the user's personal files (music, movies and such) and also depending on emaIl client used, maybe not sync email if the client saves it like Entourage does it, in big ever changing database files. Might be better to just backup the mailserver if IMAP based.
    If a user puts other large files in their homefolder (often on the Desktop) they can fill up the server fast. DVD-projects anyone?
    Mixing different versions server/client might not work too good either.
    So having said that, when syncing works it can be really good and you can restore a machine/account fast with pretty recent data. You can if in a hurry even log in from another machine using the account network home folder, getting access to the synced folders/files.
    Using Time Machine it's a one way "sync" (more like "duplicate changed and new files" - which I like) and you have to manually set TM settings on the client for what is going to be backed up and when. I do atleast don't know how to do it from/on the server. This "less intervention by the server" can be a good thing but if your users don't "behave" you might want to be in the drivers seat "saving them from themselves".
    TM backups can grow fast and probably demands more user interaction when storage space is used up.
    As with all "backup" configurations you probably want some rotating media backup of both network homes and/or TM backups so you can do a restore. Of these two, network homes are the more important one to backup "further".

  • How to set the defualt directory of where to look for a file to read

    I am reading a file from a servlet. I wanted to see where Tomcat would write the file if I didn't specify a path. The results surprised me. It wrote the file in: "C:\Documents and Settings\myusername\Start Menu\Programs\Apache Tomcat 4.1". So I looked through server.xml to see if perhaps this path was set there but didn't find anything. I right clicked on the "Start Tomcat" target to see its properties and there it was. There was a field "Start in:" and it contained the aforementioned path. I changed it to what I wanted but there has to be a way to set this in server.xml. How do I do this. my guess would be something like :
    "<Context path="" docBase="c:/theDefaultDirectory" debug="0"/>", but this didn't work. Any light on this subject would GREATLY be appreciatted,
    silas

    Well, actually, it opens file where the process is currently located on your fileSystem. since you seems to be using windows, the process is started in the directory written in the "Starts In" field. Now you could use the command line (the ugly MSDOS like window), go to some directory and starts the tomcat process from there, and the files would be created in that place.
    The docBase tells where tomcat should look when looking for pages (html jsp, etc...). If you want to use it, you can still refers to it as :
    new File (yourServlet.getServletConfig().getContextPath("/myfile.txt"))Another track to check would be to look in the System.getProperties. There has to be some property that gives the current JVM path, try to change it to the location you'd like it to be and see if it conforms to how you'd like to see it works.
    Still, remember that you can have multiple Context in your servlet container, so there's no reason for tomcat to set the JVM default path to the docBase from one or another (File is a global JVM utility, not a J2EE only feature !!).

  • How can i create work directory for Tomcat4 which is installed on Mandrake

    Hello Everybody,
    I installed Tomcat4 with the help of JPackage on Madrake Linux. It is working fine. But Unfortunatly my work folder in tomcat4 is deleted. I restarted my Tomcat, But the work folder not created. my application is not working. I need help from u people. Is there any other options to create work folder. I installed the tomcat4 from jpackage.
    Thanks in advance, Naveen Kumar Madugula

    4) Advanced Configuration - Multiple Tomcat 4 Instances
    In many circumstances, it is desirable to have a single copy of a Tomcat 4
    binary distribution shared among multiple users on the same server. To make
    this possible, you must configure a CATALINA_BASE environment variable (in
    addition to CATALINA_HOME as described above) that points to a directory
    that is unique to your instance.
    When you do this, Tomcat 4 will calculate all relative references for files in
    the following directories based on the value for CATALINA_BASE instead of
    CATALINA_HOME:
    * conf - Server configuration files (including server.xml)
    * logs - Log and output files
    * shared - For classes and resources that must be shared across all web
    applications
    * webapps - Automatically loaded web applications
    * work - Temporary working directories for web applications
    * temp - Directory used by the JVM for temporary files (java.io.tmpdir)
    If you do not set CATALINA_BASE to an explicit value, it will be initialized
    to the same value as is set for CATALINA_HOME (which means that the same
    directory is used for all relative path resolutions).
    more -> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/RUNNING.txt

  • Schedule Batch in Workspace - How to set up External Directory?

    Hello,
    I am using Hyperion Workspace 11.1.1.3 and trying to schedule a batch job. I am stuck in the create new Scheduled Batch wizard. I want to export the report in the .pdf format to an external directory. But currently I don't have external directories set up (the drop down box is empty).
    Can someone please tell me where and how I could set up external directories? I looked in Shared Services but couldn't find where I could set this up.
    Any help will be greatly appreciated.
    Thank You!

    I use the local off method but there is another way.
    Go to Settings/MIDI and use the  "Instrument Without MIDI Thru Function" selector to pick the device and channel your hardware keyboard is transmitting on.
    Settings are on a Per Song basis, they're not global like Preferences are.

  • How to set a root directory for file management in web application

    Is it possible to set a default root directory for file management for a web application ?
    We would upload some files and store them in the web server.
    When we write the uploaded files without any path, the files are written in the config directory into the jdeveloper embedded oc4j directory.
    When we write the uploaded with a relative path ("/somedir/filename"), the files are written in C:/somedir/filename.
    We would like that all file management with relative path into the web application refer automatically to a given root directory (for example defined in web.xml).
    Is it possible ?

    I'm using the standard upload in adf faces.
    The problem is not during upload. This is managed in a temporay directory defined in web.xml. The problem is for writing the file that was uploaded (upload give us an inputStream we have to write somewhere, eventually after unzipping).
    Here is an example of our current code.
    if (mimeType.equals("application/x-zip-compressed") |
    mimeType.equals("application/zip")) {
    File destZipFile =
    new File(rootDirectory + "/" + parametersDirectory +
    "/" + uploadedFile.getFilename());
    BufferedInputStream isZipFile =
    new BufferedInputStream(uploadedFile.getInputStream());
    FileOutputStream fosZipFile =
    new FileOutputStream(destZipFile);
    BufferedOutputStream bosZipFile =
    new BufferedOutputStream(fosZipFile, BUFFER);
    // read and write until last byte is encountered
    while ((currentByte = isZipFile.read(data, 0, BUFFER)) !=
    -1) {
    bosZipFile.write(data, 0, currentByte);
    }

  • How to find the working directory

    Hi all
    my csseditor is almost fully working but im having one slight problem
    my css images arent being displayed all the time (this is a bit confusing but...)
    when i reference the image via an address (http://localhost/tgheader.jpg) it works
    e.g. background-image:url('http://localhost/tgheader.jpg');
    if i reference the image via an exact path (C:/myimages/tgheader.jpg) it doesnt work
    e.g. background-image:url('C:/myimages/tgheader.jpg');
    and obviously it doesnt work if i just reference the image relatively
    e.g. backgroundimage:url('tgheader.jpg')
    so far your probably thinking what has this got to do with java, well i am wondering if it is not finding the image because maybe when i run the app it cant find working directories maybe or does the ap run from a temp directory maybe (or is it from the directory where the classes are run from) and if so if i put the images in that path then shouldnt the css know where the image is or when i render the html from a string does java omit the fact of exact paths?
    if anyone feels like this is too abstract from java to be posted here, then im sorry, im just not sure if it is a java problem or a css problem (because css works just fine using exact paths when it is run in a normal html ie environment)

    basically it is just a swing ap that runs offline
    open a css stylesheet (*.css) which is parsed into my
    stylesheet adt
    then my html header file (header.htm) is read into a
    string via getResourceAsStream
    (the header is everything that u get in a html file
    <html><head><title></title> up to <style)
    then i do a toString on my stylesheet adt to paste
    into the html string all of the styles in the
    stylesheet
    then i read in the footer info of the html with
    getResourceAsStream (footer.htm) and this contains
    the rest of the html document
    so my final html string is a complete html document
    including the styles
    i then load that string into my browser component
    which displays the html with the applied styles
    the program is just run locally and doesnt (and
    shouldnt) require any web serverok then sorry about my advice that make no sense :p
    In the light of this, I'm going to reread the whole thread ;-)

  • How to get  current working directory of the ftp server,in java application

    Hi All,
    I?m FTP?ing the file using java.net.url.
    Here is the snippet of the code:
    public void ftpFile()throws ChrsException
    try
    System.out.println("FTPing the file '"+localfile+"'");
    OutputStream os = openUploadStream(targetfile);
    FileInputStream is = new FileInputStream(localfile);
    byte[] buf = new byte[16384];
    int noOfBytesRead;
    while (true)
    //Read the data from the source File into buf
    noOfBytesRead = is.read(buf);
    if (noOfBytesRead <= 0)
    break;
    //Writes the data present in the buf to the target file
    os.write(buf, 0, noOfBytesRead);
    os.close();
    is.close();
    close();
    System.out.println ("The file '"+localfile+"' is Sucessfully FTP'd to '"+targetfile+"'");
    catch (MalformedURLException malExcp)
    System.out.println ("Invalid URL. Error in FTP'ing the file: \""+localfile+"\"");
    catch(IOException ioe)
    System.out.println ("Error in FTP'ing the file: \""+localfile+"\"");
    private OutputStream openUploadStream(String targetfile) throws MalformedURLException, IOException
    URL url = null;
    //Creates a URL object with FTP protocol
    if (user == null)
    url = new URL("ftp://" + host + "/" + targetfile + ";type=i");
    else
    url = new URL("ftp://" + user + ":" + password + "@" + host + "/" + targetfile + ";type=i");
    urlc = url.openConnection();
    //Get the OutputStream that writes to this connection.
    OutputStream os = urlc.getOutputStream();
    return os;
    Now I need to find what the current directory is when the user logs in with username and password on to the FTP server in java.
    Thanks in Advance.

    as soon as user logs in he is taken to the directory
    "ftproot/pub/abc".
    now If I execute pwd command , is hould be able to
    get to know tht user is under "ftproot/pub/abc"Three respected posters, well two plus me ;-), have just told you otherwise. The information about the current directory is (a) secure and (b) useless to the user, as he can't do anything with it. The user doesn't want to know that at all and you shouldn't try to tell him. And in any case FTP doesn't support it, again for security reasons, so you can't do it.
    Just accept it.

Maybe you are looking for

  • Playlists playing out of order

    I have a 4g 64g ipod touch.  I recently noticed that whenever I make a playlist in my computer and drag it into the ipod, the songs do not play in order.  I am positive that the shuffle isn't being used.  For example, if I start the playlist on song

  • Group by colum wise data in adobe form

    Hi,   I have a requirement to print data in adobe form thru webdynpro for abap. example; i have a table data getting from webdynpro like below. date               empno   activity. 11-11-2008     p101       x1. 11-11-2008     p101       x2. 11-11-200

  • Problem starting up my Creative Nomad Jukebox Zen X

    Ok well I have a 40GB Creative Nomad Jukebox Zen Xtra, and have had it for about a year. Now earlier today i was attempting to connect it to my computer to copy songs onto it. The battery ran out and i was not able to do this. When turning my player

  • Is another 2GB of RAM worth it?

    So it's my turn to ask you whether I should upgrade my RAM from 1 to 3GB (maximum supported memory on T60). I'm using Windows XP and Linux and am just curious whether it would be advisable to upgrade to the 3GB max or instead install another 1GB modu

  • HT5312 I'm not getting the link to change or secure my security questions for my iTunes account

    I am trying to change/rescue my security questions from my other email account. The option that appears under the securtiy question which says "secure your questions by email" doesnt appear for me. Now I'm stuck in the US store and I can't make any p