How to get list of jar files loaded by servlet container.

Hi,
I need to display in my servlet program about the list of jar files loaded by servlet container. Does it vary for each servlet container or is it same. Where can I get those details.
I need to write code to support tomcat 4x, iplanet 5.0 and websphere 6.0.
Thanks & Regards,
Nasrin.N

For curious, here are output prints for all 3 methods:
1) parsing system property
2) tschodt
3) overcast SystemClassLoader to URLClassLoader
/home/espinosa/workspace/jboss_embedded_test1/target/test-classes
/home/espinosa/workspace/jboss_embedded_test1/target/classes
/opt/javalibs/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar
/opt/javalibs/javax/jms/jms/1.1/jms-1.1.jar
/opt/javalibs/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
package com.sun.org.apache.xerces.internal.impl.validation, Java Platform API Specification, version 1.6
package com.thoughtworks.qdox.directorywalker
package com.sun.org.apache.xerces.internal.parsers, Java Platform API Specification, version 1.6
package java.util.jar, Java Platform API Specification, version 1.6
package org.testng.internal.thread
package com.sun.org.apache.xerces.internal.util, Java Platform API Specification, version 1.6
package java.net, Java Platform API Specification, version 1.6
package sun.reflect.misc, Java Platform API Specification, version 1.6
package esp.ejb.samples1.test
package sun.security.provider, Java Platform API Specification, version 1.
file:/home/espinosa/workspace/jboss_embedded_test1/target/test-classes/
file:/home/espinosa/workspace/jboss_embedded_test1/target/classes/
file:/opt/javalibs/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar
file:/opt/javalibs/javax/jms/jms/1.1/jms-1.1.jar
file:/opt/javalibs/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
...Interestingly, method 1 and 3 gives the same list, same order, same count, just format of item is a little bit different. The order is same as in Eclipse .classpath file.
Method 2 (tschodt) give significantly more items! rougly 3x! Different order (somewhat random it seems to me). Some items contain extra information, like version and string "Java Platform API Specification".
It prints not absolute paths but logical Java names.

Similar Messages

  • How to list the JAR files loaded into the Oracle Database ?

    How to list the JAR files loaded into the Oracle Database ?

    From 11.1 onwards, the below two views are available to identify the jar files loaded into the Database.
    JAVAJAR$
    JAVAJAROBJECTS$
    By querying the JAVAJAR$ view you can know information about the JAR files loaded into the Database and using JAVAJAROBJECTS$ view you can find all the java objects associated with the given JAR file.
    These views are populated everytime you use LOADJAVA with "-jarsasdbobjects" option to load your custom java classes.
    But unfortunately this feature is available only from 11.1 onwards and there is no clear workaround for above in 10.2 or earlier.

  • How to get resources from jar-files

    Hi
    in my app I load an image via the Toolkit.getImage() method.
    Works fine if the app and the image are in folders on disk.
    It fails to load the image, if the app (and the image) is packed in a jar file.
    How can I get the image from there?
    I try to get the image as follows:
    String s = getClass().getResource("MyApp.class").getFile();
    AppPath = s.substring(0,s.lastIndexOf("/"));
    String PathToImages = "/images";
    MyImage = (Image)Toolkit.getDefaultToolkit().getImage(AppPath+PathToImages+"/logo32.gif");The App starts and works, it just fails to load the images.
    Any solutions??
    thanx in advance
    Herby

    This is actually pretty easy. First a little background.
    A Jar file is just a Zip file, with a few constructs for Java.
    The getResource() method is used to create a mapping to data within the Jar file, but is actually not necessary after you know how the mapping works.
    Just to give you an example of getResource:
    // returned is a url to the resource you want from your Jar file.
    URL myURL = MyClass.class.getResource("images/myimgage.gif");
    // then you can use this URL to load the resource
    Image img = getImage(myURL);If you were you look at the value of myURL you would see something similar to the followiing.
    jar:http://www.mywebsite.com/mydir/myjarfile.jar!/images/myimage.gifJust to break it down for you.
    The line always starts with the word jar:
    Followed by the path to your jar file.
    A sepearator !/
    Then the file you are loading from the Jar file.
    jar:     path_to_jar_file     !/     path_to_resource_in_jar_fileSo if you'd like, you could just create a URL object, and define the path to the object using the above method rather than using getResource.
    Anyway, back to your code. What I would do is print out what you get for:AppPath+PathToImages+"/logo32.gif"I'm thinking you might be getting 2 "/" in your path because I think:AppPath = s.substring(0,s.lastIndexOf("/"));will leave the "/" at the end and the next line you add the "/" in front of the image directory name. So you my have the following for your image path.mypath//images

  • How to get InputStream in jar file

    Could anyone give me a tip how I can play this sound file inside the application jar file?
    I have this package: *{color:#0000ff}com.sikgraf.ui{color}*
    with *{color:#ff6600}ArquivoMagneticoUI.class{color}* and {color:#ff6600}*applause.au*{color}
    I am tyring to get the InputStream but It's being painful and so far no success
    Here are the 3 ways I tried:
    InputStream is = ArquivoMagneticoUI.class.getResourceAsStream("applause.au");
    is = getClass().getResourceAsStream("applause.au");
    is = this.getClass().getClassLoader().getResourceAsStream("applause.au");All them return:
    java.lang.NullPointerException
            at java.io.FilterInputStream.mark(FilterInputStream.java:175)
            at com.sun.media.sound.WaveFileReader.getFMT(WaveFileReader.java:241)
            at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:160)
            at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1094)What I am doing wrong?

    Thanks for your reply, I just figured out using URL:
        public static void playSound(int index) {
            String files[] = {"applause.au", "cash_register.au", "ding.au", "donkey_1.au", "duck_1.au", "siren_2.au"};
            String sound = "som/" + files[index];
            try {
                URL url = ArquivoMagneticoUI.class.getResource(sound);
                AudioInputStream ain = AudioSystem.getAudioInputStream(url);
                AudioFormat format = ain.getFormat();
                if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
                    format = new AudioFormat(
                            AudioFormat.Encoding.PCM_SIGNED,
                            format.getSampleRate(),
                            format.getSampleSizeInBits() * 2,
                            format.getChannels(),
                            format.getFrameSize() * 2,
                            format.getFrameRate(),
                            true);        // big endian
                    ain = AudioSystem.getAudioInputStream(format, ain);
                DataLine.Info info = new DataLine.Info(Clip.class, ain.getFormat(), ((int) ain.getFrameLength() * format.getFrameSize()));
                Clip clip;
                clip = (Clip) AudioSystem.getLine(info);
                clip.open(ain);
                clip.start();
            } catch (LineUnavailableException ex) {
                //Logger.getLogger(ArquivoMagneticoUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (UnsupportedAudioFileException ex) {
                //Logger.getLogger(ArquivoMagneticoUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                //Logger.getLogger(ArquivoMagneticoUI.class.getName()).log(Level.SEVERE, null, ex);
        }

  • How to get path of jar file

    I am using a class which is present in a jar file.
    There are lot of versions of this jar file are present on machine.
    I am accessing one class from this jar.
    How do I know which jar is used by application.
    How to get the path(path on machine like c:\java\lib) of this jar file.

    URL jarURL = this.getClass().getResource("/whatever.class");will return you a jar:// URL. Experiment with that. (Remember that "whatever.class" needs to be prefixed by the full name of the package the class is in.)

  • How to get list of selected files from swf to javascript ?

    Hi everybody,
    i want to make an upload script with swf and javascript. I want to do selecting files via swf then uploading files to server via javascript. I have searched SWFupload plugins but they are not working as i need. I am new here and i do some search, i see it is possible to save list of selected files in FileReferenceList array, but i dont know if is it possible to pass this array into javascript and then make upload progress via javascript ?

    Hi,
    You will not be able to get the local file paths from FileReference due to flash security restrictions.
    Hence I think it is not possible to pass the file reference data to javascript and load the same.
    Warm Regards
    Deepanjan Das
    http://deepanjandas.wordpress.com/

  • How to get the context name for a proxied servlet container

    I have been using tags to build links for applications that use Tomcat and I was wondering if tags that detect the host url can be used if the servet container is behind a proxy.
    For example let's say that the Tomcat context is called
    app_under_test
    but this url is proxied as
    testing.host/beta_testing.
    All urls built by the application should be http://testing.host/beta_testing/... not http:localhost:8080/app_under_test/...
    The only way I can think of to do this is to have a property file with a proxy url property that is used to build all application links.
    Is there a way of doing this that would not require a property file?
    Thanks for any ideas and pointers,
    -=beeky

    Hi,
    1.Goto transaction SM37.
    2. Select the Job
    3. Click on "Step" tab in the Application tool bar.
    4. You'll see the program name under "Program Name/Command" in the list displayed.
    <REMOVED BY MODERATOR>
    Regards,
    Shiny
    Edited by: Alvaro Tejada Galindo on Feb 1, 2008 1:20 PM

  • How can I get a single jar file with NetBeans?

    How can I get a single jar file with NetBeans?
    When I create the project I get these files:
    dist/lib/libreria1.jar
    dist/lib/libreria2.jar
    dist/software.jar
    The libraries that have been imported to create the project are in separate folders:
    libreria1/libreria1.jar
    libreria2/libreria2.jar
    libreria1, libreria2, dist folders are all located inside the project folder.
    I added the following code to the build.xml:
    <target name="-post-jar">
    <jar jarfile="dist/software.jar">
    <zipfileset src="${dist.jar}" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria1.jar" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria2.jar" excludes="META-INF/*" />
    <manifest>
    <attribute name="Main-Class" value="pacco.classeprincipale"/>
    </manifest>
    </jar>
    </target>
    Of course there is also the project folder:
    src/pacco/classeprincipale.form
    src/pacco/classeprincipale.java
    Can you tell me what is wrong? The error message I get is as follows:
    C:...\build.xml:75: Problem creating jar: archive is not a ZIP archive BUILD FAILED (total time: 2 seconds)

    This is not a NetBeans forum, it is a JDeveloper forum. You might want to try http://forums.netbeans.org/. I also saw your other question - try looking in the New to Java forum: New To Java

  • How to get list of drives present in local file system?

    Hi all,
    I want to show all drives and their contents using JTree.
    Does anybody know how to get list of drives present in local file system?

    Thank you!
    I have new question.
    I want to disply size and file type. Can you give ur suggestion in order to do that?
    I want to provide following using JTree
    + root <Dir> 50KB
    - file1 <txt> 10KB
    - file2 <bmp> 20KB
    + root2 <Dir> 200KB
    -file1 <jpeg> 50KB
    Is this possible?
    Plz reply..........
    bye

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How can i download these jar files to load SQL server derive

    Hi
    pls tell me how can i download these jar files and from what site i can do that to enable to load SQL server driver
    msbase.jar
    msutil.jar
    mssqlserver.jar

    if u use sqlserver 2000 u can download for free from microsoft.com
    and other sites are freetds.com i guess

  • Better way how to get list of all classpath URLs in runtime

    Hello everyone,
    How to get list of all classpath items (URLs) in runtime from Java code?
    I am aware of solution based on System.getProperty("java.class.path"). Is there any alternative?
    This solution has several drawbacks. You have to parse String output. And I not sure if it contains ALL resources (JARs, class directories) loaded by ClassLoader or just reflects -cp arguments.
    Does system property "java.class.path" contain ALL loaded JARs?
    Does it contain items (JARs, class directories) loaded by bootstrap classpath?
    What about JARs loaded in runtime?
    Is the separator ":" always same on all operation systems?
    I was looking for some Java API based solution, method like List<URL> getAllClasspathItems()
    But there is nothing like this in ClassLoader, Class, Runtime or System classes.
    For curious, here is code I use.
    String classpath = System.getProperty("java.class.path");
    StringTokenizer st = new StringTokenizer(classpath, ":");
    while (st.hasMoreElements()) {
         System.out.println(st.nextElement());
    }

    For curious, here are output prints for all 3 methods:
    1) parsing system property
    2) tschodt
    3) overcast SystemClassLoader to URLClassLoader
    /home/espinosa/workspace/jboss_embedded_test1/target/test-classes
    /home/espinosa/workspace/jboss_embedded_test1/target/classes
    /opt/javalibs/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar
    /opt/javalibs/javax/jms/jms/1.1/jms-1.1.jar
    /opt/javalibs/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
    package com.sun.org.apache.xerces.internal.impl.validation, Java Platform API Specification, version 1.6
    package com.thoughtworks.qdox.directorywalker
    package com.sun.org.apache.xerces.internal.parsers, Java Platform API Specification, version 1.6
    package java.util.jar, Java Platform API Specification, version 1.6
    package org.testng.internal.thread
    package com.sun.org.apache.xerces.internal.util, Java Platform API Specification, version 1.6
    package java.net, Java Platform API Specification, version 1.6
    package sun.reflect.misc, Java Platform API Specification, version 1.6
    package esp.ejb.samples1.test
    package sun.security.provider, Java Platform API Specification, version 1.
    file:/home/espinosa/workspace/jboss_embedded_test1/target/test-classes/
    file:/home/espinosa/workspace/jboss_embedded_test1/target/classes/
    file:/opt/javalibs/javax/ejb/ejb-api/3.0/ejb-api-3.0.jar
    file:/opt/javalibs/javax/jms/jms/1.1/jms-1.1.jar
    file:/opt/javalibs/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
    ...Interestingly, method 1 and 3 gives the same list, same order, same count, just format of item is a little bit different. The order is same as in Eclipse .classpath file.
    Method 2 (tschodt) give significantly more items! rougly 3x! Different order (somewhat random it seems to me). Some items contain extra information, like version and string "Java Platform API Specification".
    It prints not absolute paths but logical Java names.

  • How to access the database jar file using the derby 10.2.1.6 database ?

    Hi,
    How to access the database jar file using the derby 10.2.1.6 database ?
    I have used like below. And i am getting the following the error:
    "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.apache.derby.jdbc.EmbeddedDriver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)"
    My context.xml file looks like this:
    <Context crossContext="true">
    <Resource name="jdbc/derby" auth="Container"
    type="javax.sql.DataSource" driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
    url="jdbc:derby:jar(\CalypsoDemo\database.jar)samples"
    username="xxx" password="xxx" maxActive="20" maxIdle="10"
    maxWait="-1"/>
    </Context>
    What could be the reason.?
    Any suggestions will be appriciated.
    Thanks in Advance,
    Gana.

    ya, I have restarted. Can you please tell me whether the path which i am giving is right or not in the context file?
    Thanks,
    Gana.

  • How to get the most current file based on date and time stamp using SSIS?

    Hello,
    Let us assume that files get copied in a specific directory. We need to pick up a file and load data. Can you guys let me know how to get the most current file based on date and time stamp using SSIS?
    Thanks
    thx regards dinesh vv

    hi simon
    i excuted this script it is giving error..
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_9a6d985a04b249c2addd766b58fee890.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            The execution engine calls this method when the task executes.
            To access the object model, use the Dts property. Connections, variables, events,
            and logging features are available as members of the Dts property as shown in the following examples.
            To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
            To post a log entry, call Dts.Log("This is my log text", 999, null);
            To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
            To use the connections collection use something like the following:
            ConnectionManager cm = Dts.Connections.Add("OLEDB");
            cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
            Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
            To open Help, press F1.
            public void Main()
                string file = Dts.Variables["User::FolderName"].Value.ToString();
                string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::FolderName"].Value.ToString());
                System.IO.FileInfo finf;
                DateTime currentDate = new DateTime();
                string lastFile = string.Empty;
                foreach (string f in files)
                    finf = new System.IO.FileInfo(f);
                    if (finf.CreationTime >= currentDate)
                        currentDate = finf.CreationTime;
                        lastFile = f;
                Dts.Variables["User::LastFile"].Value = lastFile;
                Dts.TaskResult = (int)ScriptResults.Success;
    thx regards dinesh vv

  • How to get the number of files currently open?

    hi,
    does any one know how to get the number of files currently open in windows OS?
    e.g. lets say .txt files...
    any comment will be really appreciated.
    thanks

    Assuming that you don't want to actually do this from within Java code (which would obviously require native code), here's a utility that will give you a list of which file handles are opened by which processes (on Windows):
    http://www.sysinternals.com/ntw2k/freeware/handle.shtml
    - K

Maybe you are looking for