I am loading several different classes from several different .jars from a custom class loader in Java. I create a custom URLClassLoader, add several .jars to it and pass it on to a ServiceLoader to find the classes I want.
My question is: given a class, is there a way to discover which .jar it was loaded from?
...
I want to use the ClassLoader to load a properties file for the Properties class. I've simplified the below code to remove error handling for the purposes of this discussion:
loader = this.getClass().getClassLoader();
in = loader.getResourceAsStream("theta.properties");
result = new Properties();
result.load(in);
In the same directory...
i have an application with some timertask, connectionPools. I also developpe a classloader and sometime i need to clean the classloader. The problem is that the timer task is like a daemon with refere to a class. How can i cancel the timers from the timertask and how can i close connection pools without calling to the .remove() but using...
Ok so this is a newbie question on java, but i can't seem to get my head around it.
I have the following code inside my class
private static final String [] LIST_CODE = gerarListCode();
private static final int [][] LIST_INTEGER = new int [][] {
{947,947}, {110,103},
{947,958}, {110,120},
{947,954}, {103,107}...
Is it possible to implement a multi-threaded class loader in Java? In a meta-driven framework I need to load several hundreds of classes in advance, ie, not as lazily as the system classloader. In order to accelerate this, I would like to better utilize current multi-core CPUs. Before I dive into that, I would be interested if somebody a...
I have a java project I want to create which will be built on top of some vendor APIs. The APIs connect to servers running said vendor's software and perform various actions.
I have 2 different versions of the servers supported by 2 different API versions. Any changes to the API's are in internal implementation only. I.E. The classes,...
Hi
I have program that the number of classes loaded there is constantly rising.
How could this actually be ? Or do i misunderstand something in java about classloading?
Here is a snippet from jConsole overnight :
Could someone please tell me what could be the possible reason for such a constant classloading growth ? Or is this norm...
I observe in consecutive javacore dumps that the addresses of classloaders are changing in Websphere 6.1 (IBM JVM 1.5.0). The classes below the classloader have unchanged address. So isn't it the same classloader at a new address?
E.g. in first javacore
2CLTEXTCLLOAD Loader com/ibm/ws/classloader/CompoundClassLoader(0x0000...
I've been unsuccessfully trying to get a class from a .jar file. The .jar is located at C:\CTF.jar and contains a .class file CaptureTheFlagRules in a folder named CTF. The following code does not work:
try {
File jarFile = new File("C:\\CTF.jar");
URLClassLoader urlClassLoader = URLClassLoader.newInstance(new URL[]
{ j...
I have a java agent which instruments bytecode.
I am using the attach apis in java 6 to allow users to dynamically load the agent and instrument and deinstrument code using my java agent.
I am using the Boot-Class-Path manifest attribute to make sure my javagent classes are in the boot classpath so that my users can instrument classes li...
Hallo,
I have the following situation:
We are developing an Eclipse RCP Application and want to switch from Eclipse 3.4 to Eclipse 3.5. Our JUnit-Tests are using JUnit 4.3.1 and we have a launch configuration to start our test suite. I think I don't need to go into more details here.
The problem is:
Running the tests with Eclipse 3....
I'm confused about class visibility in OSGi. I'm running Apache Felix and loading the following bundles:
the antlr, asm, jpa and core bundles from eclipselink
an OSGi-fied jar for javax.persistence 1.99
an OSGi-fied jar with the com.mysql.jdbc driver
a bundle of my own that contains annotated entity classes and a persistence.xml
anothe...
What I'm trying
I'm trying to use java.util.TreeMap in a J2ME application. I know that TreeMap is present on J2SE but not on J2ME, so I've made some efforts to port the J2SE 6.0 TreeMap to J2ME 1.2 and included it in my Midlet Jar. This involved porting half of the collections framework, but now I'm (theoretically) done with that and wa...
I'm looking into dynamic modification of classpath. I found one solution that works nicely but it does so using an explicit call to addURL(). (presumably at startup)
However, I would like to intercept the class-loading process at runtime to locate classes if the default classloader can't seem to find them. I tried to subclass ClassLoade...
In Java, I can use a ClassLoader to get a list of classes that are already loaded, and the packages of those classes. But how do I get a list of classes that could be loaded, i.e. are on the classpath? Same with packages.
This is for a compiler; when parsing foo.bar.Baz, I want to know whether foo is a package to distinguish it from a...
I've seen this line in a sample application for using a commercial JDBC driver:
Class.forName("name.of.a.jcdb.driver")
The return value is not used.
What purpose does this line serve?
...
When trying to create a new JAXB instance inside a servlet I am getting a JAXBException saying the jaxb.properties cannot be found. I have been trying to explicitly pass the classloader with the call to JAXBContext.newInstance() but I cannot figure it out.
Here are the class loaders:
servlet classloader: oc4j:10.1.3
servlet paren...
I'm developing an application that dynamically loads a JAR, which contains the definition of a bunch of classes it uses. Everything went fine until I tried to catch an Exception-derived class that's in the dynamically loaded JAR.
The following snippet shows the issue (DynamicJarLoader is the class which actually loads the JAR; both Test...
This is a continuation of the question posted in: http://stackoverflow.com/questions/194698/how-to-load-a-jar-file-at-runtime
I am uncertain as to how to continue to the method invocation level. From my understanding,
from the clazz object, I would used getMethod or getDeclaredMethod to get a Method object from which I would call invok...
In Java How could getClass().getClassLoader() return null?
The jar the 'class' is located in is
NOT located under common/lib.
The jar is NOT being boostrap-loaded.
The ClassLoader for all classes within the jar is null.
...