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.

Similar Messages

  • How to get list of all JSF beans

    How can one get a list of all JSF beans?
    To get a particular JSF bean one does
       static public Object findJSFBean(String beanName)
          FacesContext fc = FacesContext.getCurrentInstance();
          if (fc== null) return null;
          ELContext elContext = fc.getELContext();
          Application app = fc.getApplication();
          ELResolver elResolver = app.getELResolver();
          Object result = elResolver.getValue(elContext, null, beanName);
          return result;
       }Edited by: sn72 on Sep 2, 2008 5:49 PM

    sn72 wrote:
    Several ways:
    1) Store some key in the request scope indicating the "id" of the wizard.
    2) Use a single session scoped bean which references all related session scoped beans so that you have a single main point of reference.
    3) Consider conversation scope. Apache Orchestra and JBoss Seam have their solutions.1. Can you elaborate on this?On start of the wizard generate/assign some unique identifier which you pass to the next request everytime as a hidden parameter. Use this identifier to identify a separate 'wizard conversation scope'.
    2. Yeah, this might work. But I'd need to have a common entry point (such as overriding doPost of the default faces servlet) to destroy the wizard bean whose pages have ended, which means hardcoding page names in my java code. Also, my wizard would have to register itself in this map. That's why this solution seems very much like what I was asking for originally -- that is, the session bean has a list of all wizard beans in it.Just destroying the session bean at its own ought to be sufficient. E.g. externalContext.getSessionMap().put("managedBeanName", null); destroys the session scoped bean associated with the specified managed bean name.
    3. This is the ideal solution. Unfortunately, the documentation is not very good, and I could not find examples. Hopefully this will make its way into JSF 3.0.Can't help any much with this further.

  • How to get - List of all the ad hoc reports in BO 5.1?

    Hi All,
    I want list of all the ad hoc reports in BO 5.1.
    Name of ad hoc report and user would be ideal.
    How can i get? Does anybody know how to get the list?
    Please help me.
    Thanks in advance!
    Amol Mali

    Wrong forum. Please mnove or reporst to Legacy forum:
    SAP BusinessObjects BI Legacy Products
    Ludek

  • How to get list of all sp farm solutions using powershell?

    is there any powershell script can list down all solutions deployed on farm in txt or cvs file?

    Thanks. but this is showing all features. I need only our custom developed features
    Get-SPFeature >> c:\temp\feature.txt
    Let me know how to get?

  • How to get List of  all activated Info objects in sap BI production system

    Hi Experts,
             For my requirement  I need list of all activated info objects in sap bi production system.
    Can any body suggest any thing.

    Hi,
    Check in the following table, all the below tables are for InfoObejct related only
    RSDIOBJ -
    Directory of all InfoObjects
    RSDIOBJT------ Texts of InfoObjects
    RSDIOBJ------- Directory of all InfoObjects
    RSDIOBJT----- Texts of InfoObjects
    RSDATRNAV------ Navigation Attributes
    RSDATRNAVT----- Navigation Attributes
    RSDBCHATR------ Master Data Attributes
    RSDCHABAS------- Basic Characteristics (for Characteristics,Time Characteristics, and Units)
    RSDCHA----
    Characteristics Catalog
    RSDDPA -
    Data Package Characteristic
    RSDIOBJCMP----
    Dependencies of InfoObjects
    RSKYF----
    Key Figures
    RSDTIM----
    Time Characteristics
    RSDUNI -
    Units
    Thanks
    Reddy

  • How to get list of all customers

    Good Morning ,
      I want to find out 1) LIST OF CUSTOMERS
                               2) CONTRACTS.
    WHERE IS IT THAT I CAN VIEW ALL THE SALES ORDER  AND WHERE DO I CHECK IN FOR TEH CONTRACT ANY T CODE  , please guide me on this
    Regards

    You can find out the list of all customers in the following database tables.
    KNA1----General data
    KNB1----Company code data
    KNVV--Sales area data
    KNVP---Partner function data
    Sales orders and contracts can be found using the tables VBAK and VBAP. The status of the documents can be seen in VBUK, and VBUP
    Contracts can be displayed in VA43 (VA41, VA42 and VA43)
    Hope this helps.
    Reward if this helps.

  • How to get list of all class names in a package

    hi,
    how can i get all the names of classes in a specified package, for example, if i want to get all names of
    classes in package java.util through java application.

    hi,
    if u read my question with open eyes , i wrote " with java application" not with java API .

  • How to get list of all the dates between two dates

    Hi, Can anybody please help me ..
    I have two dates in string format ("dd/MM/yyyy).I need to get all the dates in between these two dates.How can I do thin in java
    Thanks in advance

    Look at classes Calendar and SimpleDateFormat.
    And get your abstraction straight: you don't have two dates. You have two Strings that represent a date. To use them, you have to convert them to Date objects first with SDF.

  • I want to get List of all active sessions in current system

    Hi experts
    How to get list of all active sessions in current system in any internal table along with details.
    A sample code wud be helpful
    Thanks in advance.

    try this code it might help u.
    Below report execution gets the active Session list to ABAP memory
    submit rsm04000_alv and return exporting list to memory.
    refresh: gt_listobj.
    Below FM get the List output from ABAP memory to gt_listobj in HEX
    call function 'LIST_FROM_MEMORY'
      tables
        listobject = gt_listobj
      exceptions
        not_found  = 1
        others     = 2.
    if sy-subrc <> 0. " Executed successfully ?
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    This FM converts ITAB gt_listobj from HEX to ASCII
    call function 'LIST_TO_ASCI'
      tables
        listasci           = it_list
        listobject         = gt_listobj
      exceptions
        empty_list         = 1
        list_index_invalid = 2
        others             = 3.
    if sy-subrc <> 0. " Executed successfully ?
      message id sy-msgid type sy-msgty number sy-msgno
      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    This Shows the output in List format on screen
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
       i_structure_name                  = 'line'
      tables
        t_outtab                          = it_list
    exceptions
       program_error                     = 1
       others                            = 2.
    if sy-subrc <> 0. " Executed successfully ?
    message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

  • How to get list of fonts on current system(forms6i)

    Does anyone know how to get list of all available fonts on system. I want to add available fonts to list item (forms 6i) dinamicaly.

    depending on what exactly you want to know:
    System.getProperty("java.version")
    System.getProperty("java.vendor")
    System.getProperty("java.vm.version")
    System.getProperty("java.vm.vendor")
    System.getProperty("java.vm.name")
    Nick.

  • How to get list of queries .....

    how to get list of all queries on a particular cube, with descriptions?
    (meta data repository is not avilable)

    Hi..
    1. In the Bex you can fild the list of queries under a data target, by opening 'Queries'.
    In the dialog box that appears, select the Infoarea button which is in the left pane.
    You will get list of all Data targets. If you expand it you can find the queries built on those data target.
    2. If you want to get the list of queries from Tables, you have to link the following tables:
    RSZRANGE
    RSZELTXREF
    RSZELTTXT
    RSRREPDIR
    RSZSELECT
    RSZCOMPDIR
    Regards,
    Debjani..

  • Getting list of all users present in SIM

    Hi,
    I would like to update all the users (attributes of users) in SIM .
    Right now I am thinking to get list of all users present in SIM and get the view of each user and then update the particular attribute and chekin the view. and imp point to note here is I am having around 100,000 users present in SIM.
    I am thinking there could be a better solution than this...
    But I do not know which way can be used to accomplish the task.
    Can any one reply immediately with any thought on this.
    Thanks in advance.

    Run a bulk update actions you can easily get a list of all accountids by running select name from userobj;
    and in your field or in your input area specify the values u wanna update

  • How can get emails on all devices?

    How can get emails on all devices? When I read an email on my mac, my iphone doesn't download it. How can I change that setting?? I need to have all emails and all my devices!

    It sounds like your using a POP3 email account versus IMAP. With a POP3 account if you do not have the settings configured to leave email on the server the problem you describe will occur. With Outlook 2010 (on a PC for example) you can go into the account settings and configure to leave email on the server. That way both devices will see the email. Check help for your Mac email program for instructions...
    http://www.serverintellect.com/support/email/outlook-leave-on-server/
    A better solution is if your email provider uses IMAP. IMAP sync email folders between multiple devices. Meaning any device will receive the email, all sent email can be seen on the devices. If you delete email from one device the email is deleted from all the other devices. Check with your email provider to see if they offer IMAP services.
    If they do not your choices are to 1) configure email on the Mac as illustrated in the link above or 2) change email providers to something like Gmail or Outlook.com (as examples).
    Also see this for the iPad...
    Using a POP account with more than one device - Apple Support
    FWIW I use Cox IMAP email and fully sync email between a Win 8.1 Update 1 laptop, a Win 7 desktop, an iPad 4, an iPhone 4 and an iPhone 5S.

  • How to get list of company codes with current period not opened?

    Hi,
    How to get list of company codes with current period not opened?
    Is there any way we can check whether the current period is opened for all company codes.
    If not how, can we generate a report which having information of period and company code. Also please tell me, which table will have info on posting periods and company codes.
    Thanks
    Vineeth Varghese

    Hi,
    The MM periods details can be viewed In Table MARV . On the selection screen you have the option of entering the company codes , current period, year current period etc. so make the required entries and you get the all details relevant to MM periods. Also it can be downloaded as a report.Thanks

  • How to get list of software installed in a system

    How to get list of softwares installed in a system?. should i use registry to get information or control panel?
    is there any package available for this? how should i start with/
    thanks

    How to get list of softwares installed in a system?.Using native code, if at all.
    should i use registry to get information or control panel?Linux has neither.
    is there any package available for this? how should i start with/ Learn the Windows API or Google for some native tool.

Maybe you are looking for

  • SAP_INFOCUBE_DESIGNS

    I have run the report SAP_INFOCUBE_DESIGNS.  An example of the results for my cube is shown below: SMMCIM1            /BIC/DSMMCIM11      rows:          9    ratio:          7  % SMMCIM1            /BIC/DSMMCIM12      rows:         57    ratio:      

  • VPN Remote Access on ASA5510 version 7.1(2)

    Hi folks, I have surprising thing when firstly configure IPsec_ra on asa 5510 with asa version 7.1(2). I usually configure this on PIX platform and never failed. I use standard VPN remote access configuration with using provided default tunnel group.

  • Automatic inside folder linking

    There are some features which Illustrator doesn't have which are mind boggling (they've been in Freehand since the beginning). One of them is that Freehand (FH) always looked in the folder where the FH file was for its links. Only if a linked doc wer

  • Intra Comapny STO

    Hi, While transferring stock from one plant to another plant within company code (INTRA). i am facing error while creating delivery in VL10B. Error message: 4500029763 000010 Essential transfer parameters are missing in record: 4500029763 000010 Erro

  • Missing Files After Deleting OS X System Folder from Disk

    This is my first post; I'll try to be brief. I got a new computer (G5 dual) and so wanted to "clean up" my G4 tower for my wife's use. I had three hard drives in the G4, one of which was an 80 GB drive with OS X (Tiger, I think) on it. Another drive