Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

How to get the full classpath info

Thread view: 
bill_j_chen@yahoo.com - 17 Nov 2006 03:16 GMT
Hi, Java guru,

I am in a situation that I need to figure out which *.jar files the
java process is using. Basically this huge J2EE application has a lot
of customized jar files (hundreds jar files). We are troubleshooting an
application issue and suspect a wrong jar file (same name) is being
used instead of the expected one.

Here comes the question. after the java process is  running, how can we
know the full classpath which the process uses to find the class it is
looking for?

Platform:  Solaris
JDK:        1.5

Thanks.
Arne Vajhøj - 17 Nov 2006 03:39 GMT
> I am in a situation that I need to figure out which *.jar files the
> java process is using. Basically this huge J2EE application has a lot
[quoted text clipped - 5 lines]
> know the full classpath which the process uses to find the class it is
> looking for?

It is very difficult to know for sure.

But below are a small JSP file that may give you some ideas.

Arne

<%@ page import="java.net.*" %>
<ul>
<%
    ClassLoader cl = this.getClass().getClassLoader();
    while(cl != null) {
        %>
        <li><%=cl.getClass().getName()%></li>
        <%
        if(cl instanceof URLClassLoader) {
            %>
            <ul>
            <%
            URL[] urls = ((URLClassLoader)cl).getURLs();
            for(int i = 0; i < urls.length; i++) {
                %>
                <li><%=urls[i]%></li>
                <%
            }
            %>
            </ul>
            <%
        }
        cl = cl.getParent();
    }
%>
</ul>
Manish Pandit - 17 Nov 2006 03:44 GMT
You can also try <%=System.getProperty("java.class.path")%> in the JSP.

-cheers,
Manish
Arne Vajhøj - 18 Nov 2006 02:19 GMT
> You can also try <%=System.getProperty("java.class.path")%> in the JSP.

That will not return useful information in a J2EE context, because
most of the interesting stuff are loaded by classloaders created
by the app server.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.