urlclassloader

Is it possible to "add" to classpath dynamically in java?

Hi all, java -classpath ../classes;../jar;. parserTester How can i get the functionality in the above command programmatically? Like, is it possible to run as: java parserTester and get the same result? I tried using URLClassLoader but it modifies the classpath and does not add to it. Thanx! Thanks for the response Milhous. But tha...

Get size of jar file loaded by urlclassloader

Does anybody know a good way to find the file size that is dynamically loaded by urlclassloader? I am using the urlclassloader in the following manner, but need to keep track of how much bandwidth is being used. URLClassLoader sysloader = (URLClassLoader) ClassLoader .getSystemClassLoader(); Class<URLClassLoader> sysclass = URLCla...

Loading .jars during runtime: my loader works, but using setContextClassLoader doesn't?

Hello, I have an URLClassLoader named "MyClassLoader" set up with some jars on it. If I try MyClassLoader.loadClass("MyClass"); it works. If I try Thread.currentThread().setContextClassLoader(MyClassLoader); Thread.currentThread().getContextClassLoader().loadClass("MyClass"); it also works. But If I try Thread.currentThread().s...

URLClassLoader + loadClass + invoke main method on a standalone process? Java

I'm using the following method to invoke a class inside a jar file: invokeClass("path.to.classfile", new String[] {}); public static void invokeClass(String name, String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, MalformedURLException { File f = new File(System.getProperty("user.home") ...

disposing a class loader

I am using a custom class loader which extends URLClassLoader. I load some classes into my custom class loader and perform some task. Once the task is completed i want to dispose of the class loader. I tried doing that by setting the reference to null. But this does not garbage collect the class loader. Is there a way that can help wha...

can a .class file be added to the urlpath of a URLClassLoader

I have a custom class loader which extends from a URLClassLoader. I added a .class file to the urlpath using addURL(); but when i do a class.forname() using this loader i get a ClassNotFoundException. However, if i create a jar and add the jar to the urlpath, i do not get any exception. Using addURL(), can we add a .class file or a dir...

Problem reloading a jar using URLClassLoader

Hi Folks, I need to add plugin functionality to an existing application for certain parts of the application. I want to be able to add a jar at runtime and the application should be able to load a class from the jar without restarting the app. So far so good. I found some samples online using URLClassLoader and it works fine. I also wa...

java web start alternative

We're looking for an alternative to Java web start that effectively does the same thing, just better implemented. We're having massive trouble with it. We have a few offices of XP desktops, all slightly different and so far only a handful have worked without serious tweaking. Problems are to do with not playing nicely with the proxy sett...

Do I need to create custom ClassLoaders to support new archives format?

I need to support loading classes from other types of archives(tar.gz,tar.bz2...) and custom types defined by third parties. Do I need to override the 'loadClass' method to achieve that? (Perhaps theres another extension point for doing this? I still want to benefit from all the security checks made by the default class loaders). ...

Listing classes in a jar file

Hi every one! How can I dynamically load a jar file and list classes which is in it? ...

Android application running external Code/Application?

Hi all, guys. This is my target: I need an Android application which should be able to fetch data from the web (maybe an .apk or a .jar) and launch "something" from it. If it's a "trivial" class there's no problem at all. This is my Loader package com.m31.android.urlload; import java.io.BufferedInputStream; import java.io.BufferedOu...

Class Loading to an interface

Hi, I'm quite restricted in the platform I'm currently working on (JDK 1.3, BD-J). One JAR file I would like to use attempts to perform a self-integrity check on load and if it fails it goes into an inoperable state. It's quite difficult to find out why this is happening but most sources point to that it cannot find/access it self throu...

Java security: Sandboxing plugins loaded via URLClassLoader

Question summary: How do I modify the code below so that untrusted, dynamically-loaded code runs in a security sandbox while the rest of the application remains unrestricted? Why doesn't URLClassLoader just handle it like it says it does? EDIT: Updated to respond to Ani B. EDIT 2: Added updated PluginSecurityManager. My application ha...