Retrieving JAR filename

Hello,
I would like to retrieve the name of the JAR file containing the package I use currently. That is from a given instance of it I would like to know from which package it was from.
If I hard-code this info, eg 'my_packages.jar' then it works only if I run my project from the same directory:
java -jar my_packages.jar
but it cannot find it anymore if I try from another directory:
java -jar ./lib/my_packages.jar
And I absolutely don't like hard-coding filenames...
Thanks
Xavier

I found the answer myself with another post:
http://forum.java.sun.com/thread.jsp?forum=22&thread=454253

Similar Messages

  • Function library in PI 7.1 - retrieval of filename

    Hi,
    I am trying to use the function library functionality in PI 7.1 but struggling a bit.
    Basically, I want a function for the retrieval of the filename - pretty easy in goold old UDF days but not so easy now everything has moved to the function library world in PI 7.1
    I have defined the following code in the "init"  Function and Java Areas:
    DynamicConfiguration conf = (DynamicConfiguration) container.getParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    //For getting filename
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    //For getting directory
    DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    // Retrieve the filename
    String FileName = conf.get(key1);
    // Retrieve the directory
    String Directory = conf.get(key2);
    This is working ok - but I want to return these values so they can be used in mapping.
    when I try to add the statement return FileName; , the compiler then complains with the following error:
    cannot return a value from method whose result type is void return FileName;
    But where do you define the result type for a method ????? I guess it has something to do with the signature variables but I am a bit lost.
    Any help greatly appreciated.
    Thanks
    Colin.

    Hi
    Function type Void is not going to return value. It has be String type to return value. Check the function again
    Also this documents provides good info on mapping in PI 7.1
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f06d11f2-e7c2-2a10-04a9-f2f6f374cd29
    Thanks
    Gaurav

  • Display image from a folder by retrieving the filename from Database

    I have an af:table that retrieves data from my db.
    Each row of data contains a column that its value is a filename for an image.
    I have all the images stored in a folder in my project.
    How can i display the image in each row based on the filename that was retrieved from the db.
    Thank You

    Hi,
    replace the outputText component of the column with an imageObject and use
    #{row.attributeName} // replace attributeName with your column name
    as the imageObject value. You may need to prefix the folder name so the names in the database are completed to reference the file structure in your project
    Frank

  • Retrieving Jar path in the HD from within the jar?

    I have a small problem. I wrote a program which is packed in a jar file and this program is able to compile and run java files (Which I do by running javac and java processes) but the kind of files that this program compiles requires some other libraries inside the same package (In the jar file) so I am wondering how can I retrieve the jar path in the harddisk from within this jar because at the moment I ask the user where the program is and I think it is kind of ugly to ask the user where the program is from within the exact same program we are looking for.
    Hope I made myself understandable.
    Best Regards
    NooK

    Thanks for the answer. I mistakenlly ended writing a new thread (New to the forum)
    but if you would kindly look here, I have other problem now which I have been working on for a whole day.
    http://forum.java.sun.com/thread.jsp?thread=524717&forum=31&message=2514471
    Best Regards
    NooK

  • NoClassDefFoundError when jar filename contains '#' sign

    Hi,
    I'm running JRE 1.3.0_02 and have the following problem;
    The application I'm trying to run uses a jar which contains a '#' sign in its path (not something I can change 'coz I'm running it from a Synergy CM archive which creates symbolic links to cache objects)
    e.g.
    /some#dir/lib.jar
    or
    /somedir/lib#21321.jar
    The jre does not recognize this and throws an 'ClassDefNotFoundError'. If the jar's location (and filename) does not contain a '#' al works fine. The symbolic link is also not an issue.
    The machine I'm running on is a:
    'SunOS 5.8 Generic_108528-13 sun4u sparc SUNW,Netra-T4'
    TIA

    BTW: the problem does not occur with JVM 1.4.1_02

  • Retrieving jar signature from code

    I need to retrieve the signature information of a .jar file. My own
    .jar actually (the .jar file I'm running from).
    Is there some API that will allow me to retrieve the signature from an
    object reference, class name or package name ?
    Something like:
    signature = SomeClass.GetSignature(this);
    I guess what I want to do is the same thing jarsigner -verify -verbose
    does but from my code and for my own jar.
    Is there any API to do this ? is jarsigner written in JAVA and if so,
    is the source code available ?
    Thanks in advance
    Frank

    See if this helps: http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/JarEntry.html#getCertificates()

  • XSLT mapping to retrieve FileName from FILE SENDER adapter

    Hi
    I have an File Sender adapter scenario where I have switched on Adapter-specific message attributes (FileName).
    In my XSLT mapping program I need to RETRIEVE the filename and map it. Can anyone help please?
    Thx in advance

    Hi Bohamo
    Refer the following link.It provides the required solution for you.
    http://help.sap.com/saphelp_nwpi71/helpdata/EN/83/2200cb50d345c793336d9a1683163e/frameset.htm
    Thanks
    Ram

  • Retrieve filename and insert in body of htm file?

    Is there a way in Dreamweaver CS4 to retrieve the filename of the current file and insert it into the body? I want to accomplish the following:
    retrieve: currentworkingfilename.htm
    replace: href="constant/filename.htm">  (this is a consistent string that appears in all files)
    with: href="currentworkingfilename.htm">
    Thanks for any help with this.

    You will need serverside script to achieve this. In PHP this would be $_SERVER["PHP_SELF"] as in
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    </head>
    <body>
    <?php echo($_SERVER["PHP_SELF"]); ?>
    </body>
    </html>
    Gramps

  • Getting filename in FTP Adapter in BPEL

    How to retrieve the filename read by the FTP adapter in ora-bpel?

    Just figured out how to do this.
    1. Create a variable of type 'InboundHeader_msg' defined in 'ftpAdapterInboundHeader.wsdl'.
    2. Reference this in the 'Adapters' tab of the FTP adapter receive activity.

  • Two FileName in Dynamic Configuration

    Hi All,
    I have a very rare problem. In an interface which uses BPM, where file is the sender and Proxy is the target,
    there is an ABAP Class in the mapping which uses Dyanmic Configuration to retrieve the FileName and create a Proxy structure and posts it to the ECC. In this scenario, Multiple files are picked from different folder using advanced Selection and sent to BPM which uses the ABAP Class.
    When i run the interface with 5 different files placed at source, In SXMB_MONI, I can see that after 3 files are processed successfully with a single filename in the Dynamic Configuration, the 4th or the 5th one wil have 2 filenames in the dynamic configuration out of which the first filename will be the copy of the earlier processed filename and the second one wil be the actual required filename. The above behaviour keeps on chainging.
    How can this be possible as the Context Object 'FileName' can have only single filename through out the interface instance, as there is no setting of the filename done in dynamic configuration.
    Please reply if anyone has a solution to the above problem.
    Thanks.

    Hi Jaideep..
    Thanks for the reply.
    Yes.. its a serial processing. Let me explain a bit more.
    as i said above, after the 3rd BPM instance (Just as an example.. keeps on chainging), the 4th instance has a unique filename compared to before 3. but after processing, the Dynamic Configuration in SXMB_MONI will have 2 fileNames. which will have a copy of any one of the earlier filenames along with actual filename.

  • Using Javascript & Actions to resize an image and add the filename as text

    Hello,
    I am currently working on a way to take an image, resize it and add exactly what is in it's file name (before extension) as a text layer. I have succeded in this BUT am having issues with file names that require more than one line of text.
    I need the text to align to the bottom of the image & the script or action must then resize the image so that the text does not overlap.
    Any ideas on how this can be done?
    At the moment I am using:
    -"Fit Image.jsx" to resize my image to a specific size (This was included in the Photoshop CS5 scripts)
    - A script to add the file name without extension and place the file name at a specific position.
    AdFileName.jsx
    if ( documents.length > 0 )
    var originalRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    try
      var docRef = activeDocument;
      // Now create a text layer at the front
      var myLayerRef = docRef.artLayers.add();
      myLayerRef.kind = LayerKind.TEXT;
      myLayerRef.name = "Filename";
      var myTextRef = myLayerRef.textItem;
      // strip the extension off
      var fileNameNoExtension = docRef.name;
      fileNameNoExtension = fileNameNoExtension.split( "." );
      if ( fileNameNoExtension.length > 1 ) {
       fileNameNoExtension.length--;
      fileNameNoExtension = fileNameNoExtension.join(".");
      myTextRef.contents = fileNameNoExtension;
      // off set the text to be in the middle
      myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
      myTextRef.size = 12;
            myTextRef.font="Arial-BoldMT"
            //set position of text
            myTextRef.justification = Justification.CENTER;
            myTextRef.kind = TextType.PARAGRAPHTEXT;
            myTextRef.width= docRef.width;
            myTextRef.height= docRef.height/ 2;
            myTextRef.position= [0, docRef.height * 0.88];
    catch( e )
      // An error occurred. Restore ruler units, then propagate the error back
      // to the user
      preferences.rulerUnits = originalRulerUnits;
      throw e;
    // Everything went Ok. Restore ruler units
    preferences.rulerUnits = originalRulerUnits;
    else
    alert( "You must have a document open to add the filename!" );
    Can the position be changed to allow more rows of text but keep it aligned with the bottom of the layer?
    How can I script in a way to make the image resize based on the amount of text lines?
    Any help would be greatly appreciated.

    You can add a text layer any where the only thing you need to worry about is the size of the font you use.  You can normally calculate a font size by saving the images resoltuion and then setting its resolution to 72 DPI calculate a font size basied of the images pixel width and the number of characters you want in a line. After adding the text layer you can restore the image to its original resolution and align the text layer by making a selection and alignint the text layer to the selection.  There are nine posibilites like the positions in the selection you can align to like a tick tack toe board. You need to use a script to add the text layer because your retrieving the filename.  The positioning of the text layer could be done easily in an action the would use the scriot to add a text layer the do a select all  the align the added text layer to the selection.
    About your script don't make text paragraph just add new line characters to make a multi line text layer So it can be positioned easily
    I do just that with my stampexif action.  The action uses my stampexif Photoshop java script to add a multi line text layer containing some formatted EXIF data then the action centers the text layer and add a layer style to it. Link http://www.mouseprints.net/old/dpr/StampExif.jsx Example

  • Read filename of email attachment for sender mail adapter

    Hi All,
    We have a requirement to read filename of email attachment received from Sender email adapter and send details to SAP by Proxy call.
    Can we retrieve the filename of email attachment ?
    Any help on this will be really useful.
    Regards,
    Ashish

    Hi,
    >>>Can we retrieve the filename of email attachment ?
    Please see the below link, it might be useful to you.
    http://wiki.sdn.sap.com/wiki/display/XI/AdapterModulePI7.0GetAttachmentName
    Regards,
    P.Rajesh

  • Error lunching jar file

    I make a jar file
    then i lunch that jar with
    java -jar FileName.jar
    i have thi error
    Exception in thread "main" java.util.zip.ZipException: Accesso negato
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:105)
    at java.util.jar.JarFile.<init>(JarFile.java:110)
    at java.util.jar.JarFile.<init>(JarFile.java:52)
    how i can resolve this problem?

    type in shell:
    jar -tf fileNametor.jar
    what do you see?
    I recommend for a project 'pro':
    x.y.pro.src
    x.y.pro.classes
    x.y.pro.docs
    compile the .java -files from src with destination ../classes
    cd src
    java -d ..\classes *.java
    then change to pro:
    cd ..
    from there
    jar -cf pro.jar -C ./classes
    -C folder will switch to folder folder and include recursively everything, e.g.
    it.prova.foo
    (it\prova\foo.class).
    It took me a long time to find out all those silly problems, but now I stick to the same folderstructure everytime, and use ant for the build.
    This took some aditional time, but with the same structure of folders I may reuse the build.xml (95% of it) and only type:
    ant jar
    ant bin
    ant docs
    ant backup
    wich saves a lot of time and nerves.
    Take care on the naming of windows - it prefers Capital names (It\Prova) which makes no difference to windows, but for jar, java, javac.
    Please give me some dukedollars :) if it works.

  • Getting filename from HttpServletRequest

    hi,
    i am doing a simple servlet for uploading file.
    i have been googling around, but i could't find a way to retrieve the filename from the HttpServletRequest object. most solution uses another party's code.
    below is the simple code from the html that takes in the file
    <form action="/TestJSP/test2" method="post" enctype="multipart/form-data">           
                <input type="file" name="test">
                <p>
                <input type="submit" value="Upload File!">
    </form>on the servlet side, i tried using
    String filename = request.getParameter("test") ;but i keep getting a null value for the filename.
    thanks in advance!

    of lots of apache package, like the FileItemFactory
    and ServletFileUpload, even the FileItem class.The package is written for a much wider audience, it is designed to do a lot more than just read the name of the file being uploaded. I don't know if you read their Guide.
    Keep in mind that the solution posted on the other thread was custom written to solve the posters problem, which is a lot more than reading the file name.
    If you want shrunken code, then it's not that difficult:
    package test71;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.commons.fileupload.*;
    import javax.servlet.http.*;
    import java.util.List;
    public class AnotherFileUploadServlet extends HttpServlet {
        public void doPost(HttpServletRequest request, HttpServletResponse response) {
            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            List<FileItem> items = null;
            try {
                items = upload.parseRequest(request);
                for (FileItem item : items) {
                    if (!item.isFormField()) {
                        String fileName = item.getName();
                        System.out.println("File Name is: " + fileName);
            } catch (FileUploadException e) {
                e.printStackTrace();
    }

  • Adapter-Specific Attributes Retrieval

    Hello,
    I am trying to retrieve the filename from the sender message type to be used in the mapping. In order to achieve this I ticked the Adapter-Specific message properties on both Sender and receiver CC. I created a user-defined function FilenameY with the following code to retrieve the file name. I am not importing any packages.
    //write your code here
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return  ourSourceFileName; 
    Unfortunately I am getting the following message when I test mapping TESTMsgMapping. Any ideas why this is happening?????
    RuntimeException in Message-Mapping transformation: Exception:[java.lang.NullPointerException] in class com.sap.xi.tf._TESTMsgMapping_ method FilenameY$[com.sap.aii.mappingtool.tf3.rt.Context@32a38dfd]
    Thank you
    Kathir

    Hello Saravana,
    That is right we will only get the attribute values at Runtime (we cant test the mapping fully at designtime) but the problem is that I am getting a similar error message at runtime.
    During the application mapping
    com/sap/xi/tf/_TESTMsgMapping_ a
    com.sap.aii.utilxi.misc.api.BaseRuntimeException
    was thrown: RuntimeException in Message-Mapping
    transformatio~
    So I thought the above problem at runtime was down to the message during the message mapping. I am not using any parameters to pass values to the function or using any packages either. Any comments will be gratefully accepted.
    Thank you
    Kathir

Maybe you are looking for

  • Not impressed at all with the Mac Pro

    I spent years of frustration using a PC and hearing Mac users telling me how they never have issues with their computers. In January, I finally broke down and spent more than $4,000 on a Mac OS X, Version 10.5.2 with the following installed: Processo

  • HP officejet pro 8600 "not found" after installation on Dell laptop with Windows 7 op syst

    downloaded software from internet and it shows that it's been installed on computer.  Printer is on and shows that it is connected to the network.  Networks match on computer and printer.  Printer not printing from computer but did from my phone.  "p

  • HOW CAN I GET MY MAIL BACK TO ORIGINAL SETTINGS?

    I Have an iMac OS X V10.6.8 using Airport Extreme & WiFi.  I deleted some files on my Apple Mail that I added but I messed up somewhere because I don't know how to get my Mail back to the was it is when you 1st get an imac and how it's set up.  Can I

  • Variable in Analyzer

    Hi! I have a question of variables in Analyzer. I have 2 Characteristics (Start date and End Date) and I created a restricted Key Figure that has a 0NET_VALUE and the restriction of 2 User exit variables that brings the data of 2 month forward for th

  • Requisition Import for requs for each Supplier based on Sourcing Rules

    Hi, The client requires that requisitions be created based on the contract agreement per item.. So, if there are split contracts for a particular item (eg in sourcing rules, if there are 2 different suppliers each with an allocation percentage, Oracl