This class loader is used to load classes and resources from a search path of URLs referring to both JAR files and directories.
Questions tagged [urlclassloader]
286 questions
2
votes
1 answer
URLClassLoader working on Java but not in Android
My URLClassLoader implementation seems to only work on pc, but not on Android.
try {
Class> loadedClass = new URLClassLoader(
new URL[] { new File("http://10.0.2.2/myphpfile.php").toURI().toURL() })
…

Marian Klühspies
- 15,824
- 16
- 93
- 136
2
votes
0 answers
How can I create memory sandbox for objects using ClassLoaders in Scala?
I am trying to create a dynamically-loaded set of Scala classes (and objects), held in a 'sandbox' by a ClassLoader (all memory, resources, threads, etc. held within the sandbox). When refreshed, I want all memory/static objects held in the class…

Greg
- 10,696
- 22
- 68
- 98
2
votes
2 answers
How to load all the jars from a directory dynamically?
Hi I am creating a plugin which requires loading jars dynamically and accessing the classes and methods of these jars. I tried using URLClassLoader and am able to load the classes as shown below
URL myJarFile = new…

Yunkhan
- 53
- 3
- 10
2
votes
0 answers
Java keeping jar in use by jarclassloader/urlclassloader
I am loading a jar file with a JarClassLoader. After the jar file is loaded, I want to delete the file. Everything works fine except for deleting the file because the file is kept in use by the Java jvm. How do I unlock the jar? I am already closing…

Ridz
- 407
- 1
- 6
- 16
2
votes
2 answers
Load class within Jar file and get it's path
I know there are already a lot similar questions here, but I couldn't get any smarter form them. I want to load a class inside a jar file, at this point this is no problem, but when I want to pass the path to my own ClassLoader it throws an…

domizai
- 343
- 1
- 5
- 13
2
votes
2 answers
Class not available after using ClassLoader
If I load a class from file at runtime using a URLClassLoader:
ClassLoader classLoader = new URLClassLoader(new URL[] { classesUrl }, getClass().getClassLoader());
String name = fileName.replace("\\", ".").replace("/", ".").substring(0,…

Robert
- 325
- 1
- 3
- 12
2
votes
1 answer
URLClassLoader not able to Load dependencies on Linux
I am using URLClassLoader for loading classes.
Though the name of the file which i pass is loaded successfully but for classes which it referes to, NoClassDefFoundError is thrown for those. Both the classes are part of different jar files.
Even…

Bagira
- 2,149
- 4
- 26
- 55
2
votes
1 answer
Error when load JAR file classes at run time
I am trying to add JAR file to class path and load all classes from JAR file at run time. here is the code I wrote for this task (This class extends URLClassLoader)
public void loadJar(final String fName) throws IOException, IllegalAccessException,…

Korben
- 734
- 1
- 7
- 26
2
votes
1 answer
How would I fix this classloader issue?
Let me start off by saying I'm not the best at Java so I may have missed something really simple...
I'm working on a plugin system and everything works perfectly fine in eclipse but not when I actually launch the applet outside of it.
I'm trying to…

user1728017
- 67
- 1
- 6
2
votes
2 answers
URLClassLoader can't find classes
I want to use an URLClassLoader to load classes in a particular directory from a jar-archive.
The project structure is as follows
/
application.jar
/lib/
mysql.jar
log4j.jar
...
/myClasses/
class1.class
class2.class
...
The jar has…

F.P
- 17,421
- 34
- 123
- 189
2
votes
2 answers
Java JAR protection
I've coded a Java app and I plan to distribute it online. Each release will be locked with a secret serial key I made.
I need to secure my jar file from decompiler etc. Here is what I've done so far:
User enters his serial key into a form
The…

Manitoba
- 8,522
- 11
- 60
- 122
2
votes
1 answer
Does URLClassLoader.addURL(URL) honor the META-INF/MANIFEST.MF
If I have a jar that includes a Class-Path entry in the MANIFEST.MF. If I add the jar to a URLClassLoader, are the jars in the Class-Path entry also added to the classloader? Do I need to introspect the jars that I want to add to the classloader to…

vkraemer
- 9,864
- 2
- 30
- 44
2
votes
1 answer
Loading .jars during runtime: my loader works, but using setContextClassLoader doesn't?
I have an URLClassLoader named "MyClassLoader" set up with some jars on it.
If I try
MyClassLoader.loadClass("MyClass");
it works.
If I…

John Without Arms
- 153
- 1
- 5
1
vote
1 answer
Using defineClass to Dynamically Create Class from Bytes
It seems like I should be able to do this with a class loader derived from URLClassLoader that includes a loadClass():
public Class loadClass(String className, byte[] classBytes)
throws ClassNotFoundException, NoClassDefFoundError
{
Class result…

user186668
- 251
- 3
- 16
1
vote
1 answer
How exactly does URLClassLoader work? java
So I know how to use URLClassLoader, and I know what it does, what I want to know is how exactly does it do it.
Basically I'm asking: Is it a live stream? Or does it do a temporary download and reads the classes locally?
So if you where continually…

Travis
- 253
- 1
- 5
- 12