The Artima Developer Community
Sponsored Link

Java Answers Forum
Retrieve the list of loaded/used classes in a java applet

1 reply on 1 page. Most recent reply: May 22, 2002 3:28 PM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Philipp Hungerb?hler

Posts: 1
Nickname: phuiphch
Registered: May, 2002

Retrieve the list of loaded/used classes in a java applet Posted: May 22, 2002 1:10 AM
Reply to this message Reply
Advertisement
We are working on an applet that handles/displays XML based content. We could not use Microsofts XML parser because the application has to run on different browsers and operating systems. We used suns XML implementation and use it in the applet to perform several transformations. In this way we have a platform independent XML parser. The disadvantage is that the packed cab/jar is big (around 700kb). We do not use all the functionality so some of the classes could be deleted from the package.

The question is now how to identify the classes that are really used in the applet? We tried to implement a custom classloader but did not succeed. What we want is to hook into the normal classloader and get the name of the loaded call, put them into a list and get this list into a file.

Is there another way to retrieve the list of loaded/used classes or can someone give us a hint how the custom classloader has to be hook into the native classloader?

Any help would be highly appreciated.
Philipp

<code>
public class sycomW extends Applet
{
private sycom s;
public void init() {
try {
MyClassLoader myClassLoader = new MyClassLoader();
s = (sycom) myClassLoader.loadClass("sycom").newInstance();
} catch (InstantiationException e) {System.out.println("InstantiationException");
} catch (IllegalAccessException i) {System.out.println("(IllegalAccessException");
} catch (ClassNotFoundException c) {System.out.println("ClassNotFoundException" + c);
}
}

public class MyClassLoader extends ClassLoader
{
protected MyClassLoader()
{
super();
}

protected Class findClass(String name) throws ClassNotFoundException
{
System.out.println("findClass: " + name);
return super.findClass(name);
}

public Class loadClass(String name) throws ClassNotFoundException
{
System.out.println("Load class: " + name);
super.loadClass(name);
return Class.forName(name);
}

protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
{
System.out.println("Load classA: " + name);
return Class.forName(name);
}
}
</code


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Retrieve the list of loaded/used classes in a java applet Posted: May 22, 2002 3:28 PM
Reply to this message Reply
Philipp,
Have you tried to pass argument to the Appletviewer ? On my Win2K machine there is nothing one can do (apparently), but ... ?

Also you Applet could w/o any problem extend the java.applet.Applet but not use the AppletViewer. You would then be able to use the java options (see below).

Rgds,

Thomas SMETS,
SCJP2- Brussels

Finally a little remark.
This should help : http://www.artima.com/forums/howtopost.html

================

Administrator@CALVIN ~
$ java
Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] jarfile [args...]
(to execute a jar file)

where options include:
-cp -classpath <directories and zip/jar files separated by ;>
set search path for application classes and resources
-D<name>=<value>
set a system property
[b]-verbose[/b][:[b]class[/b]|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -help print this help message
-X print help on non-standard options

Flat View: This topic has 1 reply on 1 page
Topic: Urgent:Can you give me the Example how to use c methods in java Previous Topic   Next Topic Topic: application server..

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use