How to know the path of file.

i am facing a problem,i have prepared a jar file of an application, which should have a path-file in it & that path-file contains loaction from where applicatioin starts, and creates some file there. but i dont know loaction when i prepared the jar file.how to solve this problem.

but it is not in my hand, My jar file will be used by a vendor to code a Servlet which will access the classes in the jar file. it cannot be solved by My jar file.
My Question was
I have to deliver a jar file which contains my classes. This jar file will be used by a vendor to code a Servlet which will access the classes in the jar file.
One of the classes in this jar file is required to simulate a file-system (we call it "Repository"). Essentially, it creates a certain directory and reads-writes files into it.
My problem is how to specify the path (i.e. directory location) of the "Repository". Following are the possibilities I could see :
1. Hardcode the path in the java code - This is not desirable since we do not know it while I am preparing my jar-file.
2. Create a properties file, put Repository.path=... as an entry and package it with the jar-file - The problem is that sine this properties file is packaged in the jar, it is read-only. Hence, it cannot be changed at runtime.
I want to know what are the general approaches to this?

Similar Messages

  • How to know the first placed file in Application server directory

    Hi All ,
    i want to Know the First plased file in a application server directory . i have tried with
    FM EPS_GET_FILE_ATTRIBUTES but it is giving the file size. Can anybody  give some idea to get the file lastmodify property.
    Thanks & Regards
    Prithvi.

    Hi Prithvi!
    Use the methods of class CL_GUI_FRONTEND_SERVICES (if your release is at least 620, sorry otherwise).
    Method DIRECTORY_LIST_FILES will give you all files of a directory, then you can check with method FILE_GET_ATTRIBUTES for some date info.
    But maybe you can agree about a timestamp in the filename - this has to be set by the sender, but is much easier and reliable, too.
    Regards,
    Christian

  • How to find the path of Files (e.g. *.PDF,DOC,XLS) seen on PLMCfolders web?

    Hi,
    I am working on a requirment "Passing Cfolders documents/attachments to a third party document managemnt system.
    Question : Is it possible to see all the files which are uploaded in Cfolders like the ones seen in R/3 transaction AL11 at Unix level ? Do the files we see on the <b>PLM Cfolders web Browser</b> have a physical directory on SAP GUI from where we can view and download these files on the local machine ?
    Comments are most welcome !
    Regards,
    Nilesh

    Hi,
    check CFX_API_DOC_DOCUMENT_ASURL to get the URL to the document. There are other functions out there to get the content then. Just select CFX_API_DOC_* in SE37.
    Hope this helps.
    Regards,
    Jochen

  • How to find the path of Files (e.g. *.PDF,DOC) seen on PLMCfolders web?

    Hi,
    I am working on a requirment "Passing Cfolders documents/attachments to a third party document managemnt system.
    Question : Is it possible to see all the files which are uploaded in Cfolders like the ones seen in R/3 transaction AL11 at Unix level ? Do the files we see on the <b>PLM Cfolders web Browser</b> have a physical directory on SAP GUI from where we can view and download these files on the local machine ?
    Thanks in advance !
    Regards,
    Nil

    Hi,
    check CFX_API_DOC_DOCUMENT_ASURL to get the URL to the document. There are other functions out there to get the content then. Just select CFX_API_DOC_* in SE37.
    Hope this helps.
    Regards,
    Jochen

  • How to determine the path of the jar file cache of javawebstart?

    Hello, I need to know how to determine where the java web start application
    file jar cache is stored on windows system hard drive.
    I would have launch of the inner processes
    I have need to know the path of file jar .
    example if my application is myAppliation.jar
    in code generic class of myAppliation.jar i have the command runtime
    String strCmd =
    System.getProperties().getProperty("java.home") + "\\bin\\java" +
         " -cp " +
         System.getProperties().getProperty("java.class.path") + ";"
         + " anotherClass.class ";
    Runtime.getRuntime().exec(strCmd);
    the anotherClass.class has need
    of the contained library in myAppliation.jar.

    Thanks i have tried this metod and function
    java.net.URL resource = classLoader.getResource("myResource");
    if (resource != null) {
    String s = resource.toString();
    if (s.startsWith("jar:")) {
    int index = s.indexOf("!");
    if (index > 4) {
    String fileurl = s.substring(4, index);
    if (fileurl.startsWith("file:")) {
    String path = fileurl.substring(5);
    // now path is the path to the jar file in the cache containing the resource
    System.out.println("file jar: "+path);
    }

  • How dos the application will know the path of persistence.xml file

    Hi ,
    I am seeing examples for ConatierManaged EntityManager
    @PersistenceContext
    public class Test extends HttpServlet
    public void doGet()
    EntityManager em
    // JnDI Lookup code
    em = (EntityManager) ctx.lookup("java:comp/env/persistence/em");
    em.persist(Employee)
    }Inside web.xml file
    <web-app>
    <persistence-context-ref>
    <persistence-context-ref-name>persistence/em</persistence-context-ref-name>
      <persistence-unit-name>my-pu</persistence-unit-name>
    </persistence-context-ref>
    </web-app>Please tell me how the Application will know the path of persistence.xml file .
    Thank you for reading

    it is predefined; JPA always looks for the persistence.xml file in the META-INF folder.

  • How to change the default password file's name and path when the database created?

    how to change the default password file's name and path when the database created?
    null

    Usage: orapwd file=<fname> password=<password> entries=<users>
    where
    file - name of password file (mand),
    password - password for SYS and INTERNAL (mand),
    entries - maximum number of distinct DBA and OPERs (opt),
    There are no spaces around the equal-to (=) character.

  • How to give the application server file path in the module pool programming

    Hi,
         Could somebody help me how to provide the application server file path in module pool programming once the logo is uploaded to sap system.
      For eg I have imported a logo name ‘owens’ into sap system by using transaction ‘se78’; now I need to call the path in the below url,
    if container2 is initial.
    CREATE OBJECT CONTAINER2
      EXPORTING
        CONTAINER_NAME              = 'PICTURE_CONTAINER2'.
    CREATE OBJECT PICTURE2
      EXPORTING
        PARENT = CONTAINER2.
    CALL METHOD PICTURE2->SET_DISPLAY_MODE
      EXPORTING
        DISPLAY_MODE = CL_GUI_PICTURE=>display_mode_fit_center
      EXCEPTIONS
        ERROR        = 1.
    CALL METHOD PICTURE2->LOAD_PICTURE_FROM_URL
      EXPORTING
        URL    = " ? "
      EXCEPTIONS
        ERROR  = 1
        Others = 2.
    endif.
    Thanks in advance
    Deepu

    hi Deepu,
    Use FM '/SAPDMC/LSM_F4_FRONTEND_FILE' for fetching the data from the application server path/presentation server path
    Regards,
    Santosh

  • How to get the path when i select a directory or a file in a JTree

    How to get the path when i select a directory or a file in a JTree

    import java.lang.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.HeadlessException;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Iterator;
    * @author Frederic FOURGEOT
    * @version 1.0
    public class JTreeFolder extends JPanel {
    protected DefaultMutableTreeNode racine;
    JTree tree;
    protected JScrollPane scrollpane;
    final static int MAX_LEVEL = 1; // niveau max de descente "direct" dans l'arborescence
    * Sous-classe FSNode
    * @author Frederic FOURGEOT
    * @version 1.0
    private class FSNode extends DefaultMutableTreeNode {
    File file; // contient le fichier li� au noeud
    * Constructeur non visible
    private FSNode() {
    super();
    * Constructeur par initialisation
    * @param userObject Object
    FSNode(Object userObject) {
    super(userObject);
    * Constructeur par initialisation
    * @param userObject Object
    * @param newFile File
    FSNode(Object userObject, File newFile) {
    super(userObject);
    file = newFile;
    * Definit le fichier lie au noeud
    * @param newFile File
    public void setFile(File newFile) {
    file = newFile;
    * Renvoi le fichier lie au noeud
    * @return File
    public File getFile() {
    return file;
    public JTree getJTree(){
         return tree ;
    * Constructeur
    * @throws HeadlessException
    public JTreeFolder() throws HeadlessException {
    File[] drive;
    tree = new JTree();
    // cr�ation du noeud sup�rieur
    racine = new DefaultMutableTreeNode("Poste de travail");
    // cr�ation d'un noeud pour chaque lecteur
    drive = File.listRoots();
    for (int i = 0 ; i < drive.length ; i++) {
    FSNode node = new FSNode(drive, drive[i]);
    addFolder(drive[i], node); // on descend dans l'arborescence du lecteur jusqu'� MAX_LEVEL
    racine.add(node);
    // Gestion d'evenement sur JTree (on �coute les evenements TreeExpansion)
    tree.addTreeExpansionListener(new TreeExpansionListener() {
    public void treeExpanded(TreeExpansionEvent e) {
    // lorsqu'un noeud est ouvert
    // on descend dans l'arborescence du noeud jusqu'� MAX_LEVEL
    TreePath path = e.getPath();
    FSNode node = (FSNode)path.getLastPathComponent();
    addFolder(node);
    ((DefaultTreeModel)tree.getModel()).reload(node); // on recharche uniquement le noeud
    public void treeCollapsed(TreeExpansionEvent e) {
    // lorsqu'un noeud est referm�
    //RIEN
    // alimentation du JTree
    DefaultTreeModel model = new DefaultTreeModel(racine);
    tree.setModel(model);
         setLayout(null);
    // ajout du JTree au formulaire
    tree.setBounds(0, 0, 240, 290);
    scrollpane = new JScrollPane(tree);
         add(scrollpane);
         scrollpane.setBounds(0, 0, 240, 290);
    * Recuperation des sous-elements d'un repertoire
    * @param driveOrDir
    * @param node
    public void addFolder(File driveOrDir, DefaultMutableTreeNode node) {
    setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
    addFolder(driveOrDir, node, 0);
    setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
    * Recuperation des sous-elements d'un repertoire
    * (avec niveau pour r�cursivit� et arr�t sur MAX_LEVEL)
    * @param driveOrDir File
    * @param node DefaultMutableTreeNode
    * @param level int
    private void addFolder(File driveOrDir, DefaultMutableTreeNode node, int level) {
    File[] fileList;
    fileList = driveOrDir.listFiles();
    if (fileList != null) {
    sortFiles(fileList); // on tri les elements
    // on ne cherche pas plus loin que le niveau maximal d�finit
    if (level > MAX_LEVEL - 1) {return;}
    // pour chaque �l�ment
    try {
    for (int i = 0; i < fileList.length; i++) {
    // en fonction du type d'�l�ment
    if (fileList[i].isDirectory()) {
    // si c'est un r�pertoire on cr�� un nouveau noeud
    FSNode dir = new FSNode(fileList[i].getName(), fileList[i]);
    node.add(dir);
    // on recherche les �l�ments (r�cursivit�)
    addFolder(fileList[i], dir, ++level);
    if (fileList[i].isFile()) {
    // si c'est un fichier on ajoute l'�l�ment au noeud
    node.add(new FSNode(fileList[i].getName(), fileList[i]));
    catch (NullPointerException e) {
    // rien
    * Recuperation des sous-elements d'un noeud
    * @param node
    public void addFolder(FSNode node) {
    setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
    for (int i = 0 ; i < node.getChildCount() ; i++) {
    addFolder(((FSNode)node.getChildAt(i)).getFile(), (FSNode)node.getChildAt(i));
    setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
    * Tri une liste de fichier
    * @param listFile
    public void sortFiles(File[] listFile) {
    triRapide(listFile, 0, listFile.length - 1);
    * QuickSort : Partition
    * @param listFile
    * @param deb
    * @param fin
    * @return
    private int partition(File[] listFile, int deb, int fin) {
    int compt = deb;
    File pivot = listFile[deb];
    int i = deb - 1;
    int j = fin + 1;
    while (true) {
    do {
    j--;
    } while (listFile[j].getName().compareToIgnoreCase(pivot.getName()) > 0);
    do {
    i++;
    } while (listFile[i].getName().compareToIgnoreCase(pivot.getName()) < 0);
    if (i < j) {
    echanger(listFile, i, j);
    } else {
    return j;
    * Tri rapide : quick sort
    * @param listFile
    * @param deb
    * @param fin
    private void triRapide(File[] listFile, int deb, int fin) {
    if (deb < fin) {
    int positionPivot = partition(listFile, deb, fin);
    triRapide(listFile, deb, positionPivot);
    triRapide(listFile, positionPivot + 1, fin);
    * QuickSort : echanger
    * @param listFile
    * @param posa
    * @param posb
    private void echanger(File[] listFile, int posa, int posb) {
    File tmpFile = listFile[posa];
    listFile[posa] = listFile[posb];
    listFile[posb] = tmpFile;

  • How 2 get the path of a file

    how 2 get the path of a file Using jsp
    i have tried getPath...but i'm geting the error
    The method getPath(String) is undefined for the type HttpServletRequest
    any idea how 2 get the path of a file

    You need ServletContext#getRealPath().
    API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

  • How 2 get the path of a file Using jsp

    how 2 get the path of a file Using jsp
    i have tried getPath...but i'm geting the error
    The method getPath(String) is undefined for the type HttpServletRequest
    any idea how 2 get the path of a file

    You need ServletContext#getRealPath().
    API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

  • How to change the path of sysprep files that were copied to reference computer when i capture the image from reference.

    Dears ,,
    how to change the path that sysprep were copied to reference computer when i capture the image from reference.
    Should i modify some codes in LTIAPPLY.wsf? how to modify it?
    Thanks.

    Sysprep and capture has *Three* steps.
    1. Run sysprep on the local machine (easy).
    2. Copy WinPE down to the local machine so we can reboot into winpe for capture.
    3. Capture the drive in an *offline* state from within WinPE.
    What is most likely happening is that you are having problems with step #2. 100MB is *WAY* too small to copy down WinPE. By default MDT will make this System partition much bigger, 499MB. IF you install Windows 7 from the default media. IT will only create
    a 100MB partition.
    By default MDT 2012 Update 1 and greater *should* recover to a fallback drive with the OS on it, however if you are running older versions that might not happen correctly.
    If you are still having problems, copy your BDD.log file to a public share like OneDrive and copy the link here.
    Keith Garner - keithga.wordpress.com

  • How to know the full path which is being used in the dataconnection .

    How to know the full path which is being used in the dataconnection without going and looking into coding.
    I am new to crystal reports.
    Plz advice.Thanks in advance
    Jay

    This forum is dedicated to topics related to custom application development or deployment with Crystal Reports in .Net. This includes full versions of Crystal Reports as well as those versions of Crystal Reports bundled with Microsoft Visual Studio .Net.
    As you do not want to do any coding, this query is in the wrong forum. However, in most versions of Crystal Reports, you can look up the database connection information by simply opening the report in the CR designer. Then go to the database menu and select "Set Datasource Location..."
    Ludek

  • I have one file ss_fpga.rbt,abcd.txt how to know the details of the file

    i have  one file  ss_fpga.rbt,abcd.txt how to know  the details  of the file  (when was the date created ,when was date modfied,owner) any function is there like   GetFileInfo

    Yes there is some, called stat(), look the links in your post in stack overflow, there is a lot of link in the anser.
    They talk about sys/stat.h a C header, witch contain the stat() function.
    stat() return a lot of things (size, changes, access etc) about files. look the "here" everywhere in the Yann anser, UP his anser and put the subject as resolved.
    Thanks,

  • How to retrieve the path and the name of the destination file in a link annotation

    Hi,
    In C++:
    How to retrieve the path and the name of the destination file in a link annotation and a Launch action.
    Sample of my code:
    //Determine if the annotation is a Link annotation
    if (PDAnnotGetSubtype(annot) == ASAtomFromString("Link")) {
    //Determine if the action is a Launch action
    if (PDActionGetSubtype(action) == ASAtomFromString("Launch")) {
    // What is the method ?
    Regards
    David G

    In general, get the annotation as a Cos object and examine it, in
    accordance with the PDF Reference.
    Aandi Inston

Maybe you are looking for