Creation of file using relative path

I am working on JSP
I want to create a file object by passing a relative path as parameter to
File f = new File("<relative path>");
i encounter the following error
"it says server cannot find the file in the path specified."
I have searched the forums but not able to get any relevant expalination.
Its an urgent requirement. So please reply. Thanks in advance.

I notice that servletContext.getRealPath()
returns path from root directory to the ../webapps/examples folder
am i correct or it can get real path for any file residing in any subfolder
like ../webapps/examples/a/df/a.txt ?

Similar Messages

  • Can't open files using relative paths

    That seems straightforward but i can't figure out how I can have access to
    image files stored in the same directory with the compiled classes.
    Here's my what I want to do
    windowsButton = new JButton("Windows", new ImageIcon("icon_cool.gif"));
    but it doesn't work :(
    however if i specify the absolute path to images everything works fine.
    I tried also copying images into the source directory it didn't work.
    I thought about a workaround like If i could get the absolute path of the
    class that loads images that would be great but i have no clue how to get
    that absolute path.
    i code in netbeans so src and classes are separated.
    Thanks in advance for your replies. If u feel like u need more details i'll
    try to provide them :)

    In addition to jverd's answer, here is a tutorial
    dealing with images and icons
    "How to Use Icons":
    http://java.sun.com/docs/books/tutorial/uiswing/misc/i
    con.html
    It gices some examples of how to use the
    getResource() method to load your images.As the tutorial points out, simple path is more general than using class loader and resources for it.
    If OP's problem is on the line of this simplicity, he has to learn relevant details of a particular IDE or,
    if he hates the kind of learning, he'd be better off throwing away and foget it forever.
    It reminds me of a long-time belief that IDE is too big an /unnecessary/ obstacle for beginners.
    Does anyone know, does Eclipse have similar awkwardness for resource path issue?

  • Can any one suggest me how can I use relative path inside SSIS pacakge to access config file ?

    Can any one suggest me how can I use relative path inside SSIS pacakge to access config file ? Please help me as its urgent.THanks for your help in advance.

    Hi Jay,
    SSIS can only recognize the absolute path of a XML Configuration file, the relative path is not supported. Furthermore, if the XML Configuration file is already generated, we can use the Environment variable package configuration type instead so that
    SSIS runtime automatically looks for the configuration file from the path defined in the environment variable. This is convenient when we need to deploy a package to different environment. We only need to define the environment variable for package configurations
    once on each server, and then the variable can be used by all the packages on this server.
    Regards,
    Mike Yin
    TechNet Community Support

  • How to read/know/use  relative paths in java files ?

    I am able to access files in java after using the
    String TxtURL = "file:///c:/files/TEXTS/";and then loop
    = new File(ma.TxtURL +filename );However , I need to use this in several drives , C , D E etc , how can I use relative path ?
    I used these but they didn't work
    String TxtURL = "file:///TEXTS/";
    String TxtURL = "file:////TEXTS/";
    String TxtURL = "file:///./TEXTS/";
    String TxtURL = "file:///../TEXTS/";

    ya batch , I want to run a java program from batch file
    java C:\...\fileand as u know that C will change , so any suggestions/solutions ?
    thanks

  • Using Relative Path instead of Full Path OMBPlus

    Can we use relative paths in OMBPlus scripts instead of full paths. For example all my OMBplus (tcl) scripts are in folder;
    C:\tfsroot2\Interfaces and Extracts\branches\Interfaces and Extracts1.1\000 - OWB Prototype\deploy\ora.stg
    and the MDX file I would like to deploy is in
    C:\tfsroot2\Interfaces and Extracts\branches\Interfaces and Extracts1.1\000 - OWB Prototype\deploy\ora.stg\scripts\dwextract\tables
    but when I try to use
    OMBIMPORT MDL_FILE '../scripts/dwextract/tables/$tblName.mdx'
    instead of
    OMBIMPORT MDL_FILE 'C:/tfsroot2/Interfaces and Extracts/branches/Interfaces and Extracts1.1/000 - OWB Prototype/deploy/ora.stg/scripts/dwextract/tables/$tblName.mdx'
    It does not work.
    I use
    call "C:\OraHome_1\owb\bin\win32\OMBPlus.bat" "C:\tfsroot2\Interfaces and Extracts\branches\Interfaces and Extracts1.1\000 - OWB Prototype\deploy\ora.stg\OMB_DEPLOY_TBL.tcl" XTRCT_WRK_INPUT_FILE
    in order to execute.
    I think it is because It set the OMBPlus.bat location is a base folder. Any way to overcome this issue and use relative paths instead of the full path?

    OK, a couple of things. First, you need to remember that TCL treats back-slashes as an escape character. Always use forward slashes in your paths, or double up the back slashes .
    So, this should work:
    CD "C:\tfsroot2\Interfaces and Extracts\branches\Interfaces and Extracts1.1\000 - OWB Prototype\deploy\ora.stg"
    call OMBPlus.bat "C:\\tfsroot2\\Interfaces and Extracts\\branches\\Interfaces and Extracts1.1\\000 - OWB Prototype\\deploy\\ora.stg\\OMB_DEPLOY_TBL.tcl" XTRCT_WRK_INPUT_FILEor this:
    CD "C\tfsroot2\Interfaces and Extracts\branches\Interfaces and Extracts1.1\000 - OWB Prototype\deploy\ora.stg"
    call OMBPlus.bat "C:/tfsroot2/Interfaces and Extracts/branches/Interfaces and Extracts1.1/000 - OWB Prototype/deploy/ora.stg/OMB_DEPLOY_TBL.tcl" XTRCT_WRK_INPUT_FILEAs an FYI for OMB, if you are prone to doing a lot of scripts and so building libraries of common functions, you can also easilly use the "file" command in order to determine the current directory at runtime so you can plunk your script anywhere with it's required libraries and it will be able to source them at runtime.
    For example, all our scripts have this basic bit of code at the beginning so we can pass them between developers and it doesn't matter where anyone put their script directory - the scripts will find the libraries as long as they are co-located:
    #  Get Current Directory and time
    set dtstmp     [ clock format [clock seconds] -format {%Y%m%d_%H%M}]
    set scrpt      [ file split [file root [info script]]]
    set scriptDir  [ file dirname [info script]]
    set scriptName [ lindex $scrpt [expr [llength $scrpt]-1]]
    set cnfg_lib "$scriptDir/ombplus_config.tcl"
    set owb_lib  "$scriptDir/omb_library.tcl"
    set sql_lib  "$scriptDir/omb_sql_library.tcl"
    #  Import Lbraries
    #      Assumes that owb_config, omb_library, and omb_sql_library are in the same directory as this
    #      script.
    #get config file
    if [catch { set retstr [ source $cnfg_lib ] } errmsg] {
       puts "**********************************************************************"
       puts "* Libraries are missing from the current directory. Exiting.... *"
       puts "**********************************************************************"
       return -code 2
    #get standard library
    source $owb_lib
    source $sql_lib
    #  Set Logfile
    #    This will overwrite anything set in the config file.
    set LOG_PATH "$scriptDir/logs"
    file mkdir $LOG_PATH
    set    SPOOLFILE  ""
    append SPOOLFILE $LOG_PATH "/log_"  $scriptName "_" $tabName "_" $dtstmp ".txt"
    # Now the main script body goes from here.Cheers,
    Mike
    Edited by: zeppo on Aug 4, 2009 7:02 AM
    Edited by: zeppo on Aug 4, 2009 7:03 AM

  • Why cant I use relative paths in Netbeans

    Why cant I use relative paths in Netbeans to files on my PC.
    I want to be able to copy my project folder between different drives and pcs dont want to edit the code everytime I do.
    BTW I didnt know where on the forum to post this. Just in case this is the wrong place.

    When I use relative paths it doesnt see the files. Like when I want to add an image to a panel. If I use '../image.jpg' it wont work but if I use 'd:\javafiles\images\image.jpg\ it will work.
    Cant seem to fix it.

  • Can't use relative paths in jsp pages or javabeans

    Hi everyone,
    Can someone please help me with this little problem.
    When I want to use in a JSP page the object 'FileReadInput' to read in a file, it can't find when I only give the filename. The target file and source file are in the same directory so I would expect if I only give the filename, it will automatically search in the current directory. But when I give the complete absolute path, everything works fine. Is it possible to use relative paths in a jsp or javabean file?
    By the way, I am working with JDeveloper from Oracle. (maybe that has something to do with my problem)
    Can someone help me???
    Thx

    My dear friend,
    It will not work at all. coz, for any jsp file, ur application server will create a .java file and then .class file in a directory other than the directory where ur .jsp file present. that's why, ur file to be read can't be found. that's why use the following.
    String path=getServletConfig().getServletContext().getRealPath("/")+File.seperator+"yourfilename";

  • How to use relative paths in Captivate 8 / Cómo usar URL's relativas en Captivate 8

    Hello, I have developed a bunch of courses which will be migrated to a new site and I am having trouble changing the absolute paths into relative URL's to resources such as PDF files inserted into the scorm packages. I cannot find information on how to use relative paths in Captivate. Please help. Thank you.

    I have the same issue with relative links using Captivate 8.  I am trying to load Captivate modules into an LMS using relative links to document files within the LMS.  The links work fine during a site page test so not an issue in the LMS, but from the Captivate module they aren't working....
    Help?

  • Menu using relative paths

    Hi, I have flash menu all using relative paths to the html
    files. I also have some files in a separate folder for
    organization. I add the folder paths to get to the html files
    within the folder, but when I get into that folders file, i cant
    get back out. If I add ../ to the other files, it of course brings
    me out, but cant get to the other files. I hope that makes sense,
    Should I just use absolute paths?
    file.html
    /folder/file.html
    otherfile.html
    thanks,
    Josh

    absolute would probably work best.
    When a link brings you into a folder (/folder/file.html), if
    the same set of links is there and you click a link that is
    supposed to bring you to home (index.html), it tries to open
    (/folder/index.html), not index.html. Make sense?
    Thanks,
    Josh

  • Reconnect Media - Unable to Reconnect All Files in Relative Path

    I have a project that I have restored from a DLT backup. The project file and the all the media are now on a SAN which I access from my G5. Since this project originated on a different editor's computer all of the clips in my project are ostensibly offline within my project. All of the media files are located in a single capture scratch folder on the SAN with the same filenames and reel numbers. As such, I figured that when I used "Reconnect Media" with "Reconnect All Files in Relative Path" checked, all of the files would automatically relink. However, everytime I attempt to do this, the only file that is reconnected is the original file which I manually selected to establish the file path to the rest of my media. If I use the "Search" functionality and instruct FCP to search the capture scratch folder one file at a time, without fail, it will automatically find the media and reconnect it. Yet, I cannot seem to batch reonnect, as it were.
    My question is this: If all of the media files are located in the same capture scratch folder (i.e. same relative path), why won't FCP automatically reconnect all the files in that folder to the corresponding offline clips?
    I have attempted to reconnect the media on two different machines. The same issue arose on both machines. This leads me to believe that the problem may be a result of some issue with the filesystem on the SAN. Also, I have run FCP rescue and attempted a reconnect with both a clean backup and entirely new preference files, to no avail.

    Hi Nat,
    I don't have a direct solution, and you might you've been doing this already. Although you didn't describe this. I think that what I would try to do is:
    - Copy the project (backup).
    - Open the project, and when it tells you that 132 clips and 714 render-files are offline, I'd select the checkboxes in order to 'Forget' the files.
    - Hit OK.
    - FCP 'forgot' all the links to the original files. So you forced errors from that perspective by doing this.
    - Try to reconnect again.
    Just a thought...
    All the best
    Rienk
    PS What version FCP are you running?

  • Using relative path for in file/ftp adapter

    Hi All,
    How to have a relative path for file/ ftp adapter's inbound/outbound operation?
    Example: Consider $ORA_HOME = /home/oracle --> This environment variable can be different on different machines
    i want to drop a file in to $ORA_HOME/folder1/folder2 (Or poll for a file).
    <partnerLinkBinding name="FTP">
    <property name="wsdlLocation">FTP.wsdl</property>
    <property name="out_dir" type="LogicalDirectory">What do i write here???</property>
    <property name="retryInterval">60</property>
    </partnerLinkBinding>
    if i cant configure this in partner link section or in activation agent sction, how else do i achieve this?
    i am using 10.1.3.* version.
    Thanks in advance.
    Roshan.

    You can achive it using the deployment scripts if the directory is changing on the basis of the environment
    If you want to change at run time than you can use the jca properties to set using the variables at runtime.
    Regards,
    Ajay

  • Use Relative Path for Photoshop Action?

    I have a Photoshop Action that is programmed to open an existing file located in a specific directory.  The path to this directory is an absolute path, i.e.:
    C:\Program Files\Photoshop Actions\filename.jpg
    As long as the Action can find the file in the specified absolute path, everything works fine.
    My problem is that if someone tries to run this Action on a different computer (like a Mac), the path specified in the action does not exist and the Action will not work.
    The simple solution to this would be to make the action open the file located at a relative path.  This way no matter what computer the action is run on, it will always be able to find the file.
    Unfortunately, I don't think Photoshop Actions allow relative paths.  Does anyone know if using a relative path in an action is possible?
    Failing this, how would I use a Photoshop Script to somehow direct the Action to find the correct location of the file?  Or is there a better solution?

    The idea that I use in the xtools installer and else where is this:
    1) Convert the action file to XML.
    2) Package the XML file and the apps/ActionFileFromXML script with your stuff.
    3) An installer script will do a 'replace' (or whatever) on the XML file so that the paths are converted to whatever is needed.
    4) The new XML is saved and then converted to a .atn file which is then loaded.
    There is an xtools forum at ps-scripts.com that may have some info in addition to the PDF file that comes with the package.
    -X

  • Links to PDF files with relative paths from a Captivate 4 project

    I'm creating a presentation in Captivate 4 (I'm making an exe file) with some links to PDF files; the links are buttons with the 'open URL or file' set. The presentation will be distributed in CDs and obviously the links will not work for they point to an absolute path in my PC. Is there another way to display external files? thanks

    "file:\file folder\filename" is not a relative path.  It's still an absolute path because you're specifying the path all the way from the root drive, whether you used a drive letter or not.
    A relative path shows where to find the other file in relation to the file that is calling it.
    Relative paths look like this:
    myDoc.doc (if the file is in the same directory as the file calling it)
    folderName/myDoc.doc (if the file is inside a folder in the same directory as the file calling it)
    ../myDoc.doc (if the file is located in the parent directory above the file that is calling it)
    ../../myDoc.doc (if the file is located two levels above the file that is calling it)
    etc
    Here's a tutorial that explains it better: http://www.communitymx.com/content/article.cfm?cid=230ad

  • External casts not using relative paths when  protect movie

    We make educational software using Director - the basic form
    of the software is a stub movie projector with a load of protected
    movies in a series of folders and sub folders - shared resources
    are located in external casts within the folder hierarchy but not
    necessarily within the same folder as the movie - this has worked
    fine for ages. Navigation between movies is working fine, but..
    ..some of the movies are looking for external casts at their
    original locations (absolute paths) rather than relative to the
    movie file, so I can't port the project to another computer/
    release the software without getting the error messages. Even when
    I recreate the movies from scratch and link up the external casts,
    I am getting the same result, almost as if the dir to dxr process
    is not switching the movies from absolute paths to relative
    paths..??
    Any ideas appreciated!
    Tom

    Hi,
    If I understand the problem correctly, I see two ways of going forward:
    1. Hard code the entire URL.
    2. Calculate the correct URL with JavaScript.  I have a JS function for that on: http://www.wvanweelden.eu/blog/2012/08/03/get-relative-link-project-root
    Greet,
    Willam

  • Adobe Flash CS5 - Using Relative Paths

    Hiya Guys, I'm relatively new to Adobe Flash CS5, bu have managed to create an index.swf to link together all my work for this project I've just completed. However, the index.swf, along with all my other files will be relocated, as in burnt onto a CD or moved onto a USB. When the file directories change, the links obviouly break, so I needed some help setting up some relative paths for my files so that they don't break. All my files are stored under a PROJECT file, this then consists of five other folders, consisting of subfolders and each of these subfolders have their own documents. So for example, PROJECT\PARTONE\DATABASES\Database.accdb
    I have used absolute file paths, but they keep on breaking when moving directories. Can someone PLEASE help?!

    Well I did use actionscript for creating the actual index and effects, but AS3 was used no further for the index. I created an index which had links Part 1, Part 2 ,3,4,5 and clicking on each of them lead to different frames (using the mouseclick, goto and stop at frame (x) function.) Clicking on part one for example would lead to list of documents in that part. Sorry I can't be of any help, I'm totally new to this

Maybe you are looking for

  • Error while invoking web service over SSL

    While making a SSL Connections to web service i am getting the below mentioned error in spite of configuring the certificate provided by the client onto WLS. I tried adding the certificate to the default DemoTrust and DemoIdentity Keystores. The erro

  • Opening driving directions in new browser window

    I have installed the Web Assist Google Pro Maps extension and would like for the div containing the driving directions results: <div id="wagmp_directions_2" to appear in a new browser window. However, when I open the tag inspector, it says "locked re

  • Maintenance Order Settlement Rule Mandatory

    Dear Masters, I want to make the settlement rule to be mandatory at the time of releasing a maintenance order,can anybody tell me how to achieve this? Hope for a sooner reply. Thanks in advance. Chin2

  • Dynamic creation of date in selection variant

    Hi All, I have a Z program for updating a field in BOM item. One of the input field in the report is "Valid From Date". Actually the current date is automatically fetched through a function module and it is defaulted in that field.  Our client is usi

  • W520 Win 8.1 Bluetooth LED

    Hi! Is it possible to switch off Bluetooth in Windows 8.1? Disabling it in device manager or in system settings seems not working(LED is still on).