Questions tagged [urlclassloader]

This class loader is used to load classes and resources from a search path of URLs referring to both JAR files and directories.

286 questions
34
votes
3 answers

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:…
Robert J. Walker
  • 10,027
  • 5
  • 46
  • 65
23
votes
7 answers

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

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…
gimbal
20
votes
2 answers

Add jar to classpath at runtime under java 9

Until java9 for adding external jar to classpath in runtime by programmatically everybody used: URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Method method = URLClassLoader.class.getDeclaredMethod("addURL", new…
Evgeniy Egorov
  • 223
  • 2
  • 7
19
votes
8 answers

Java 9, compatability issue with ClassLoader.getSystemClassLoader

The following code adds jar file to the build path, it works fine with Java 8. However, it throws exception with Java 9, the exception is related to the cast to URLClassLoader. Any ideas how this can be solved? an optimal solution will edit it to…
Mostafa abdo
  • 616
  • 1
  • 8
  • 21
19
votes
6 answers

Problem reloading a jar using URLClassLoader

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.…
samitgaur
  • 5,601
  • 2
  • 29
  • 33
15
votes
5 answers

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…
David
  • 1,862
  • 2
  • 22
  • 35
14
votes
5 answers

Listing classes in a jar file

How can I dynamically load a jar file and list classes which is in it?
Hossein Margani
  • 1,056
  • 2
  • 15
  • 35
11
votes
6 answers

How do I "close" a ClassLoader?

I have a case where I need to create a lot of class loaders in my application to temporarily make some code visible while user supplied scripts are running. I'm using an URLClassLoader for this and it works pretty well. When the script terminates, I…
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
11
votes
4 answers

Hive: AppClassLoader cannot be cast to URLClassLoader although using JDK8

After installing jdk9 I have been seeing this problem: $hive Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in…
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560
8
votes
1 answer

OneJar and dynamic class loading

We're currently investigating the use of OneJar in our application (for a number reasons), but our application makes use of a number of custom URLClassloaders to load application extensions. When bundled as a "OneJar" Jar, we get ClassNotFound…
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
7
votes
3 answers

Java example with ClassLoader

I have small problem. I learn java SE and find class ClassLoader. I try to use it in below code: I am trying to use URLClassLoader to dynamically load a class at runtime. URLClassLoader urlcl = new URLClassLoader(new URL[] {new…
Michał
  • 145
  • 1
  • 4
  • 12
7
votes
2 answers

Java classLoader dilemma with locked jars

I was playing around with classLoaders in Java and noticed a strange thing. If a classLoader loads a class from a jar, this jar is locked indefinitely even if you unreference your classLoader. In the below example, the jar contains a class called…
Adel Boutros
  • 10,205
  • 7
  • 55
  • 89
6
votes
1 answer

Java 9 - add jar dynamically at runtime

I've got a classloader problem with Java 9. This code worked with previous Java versions: private static void addNewURL(URL u) throws IOException { final Class[] newParameters = new Class[]{URL.class}; URLClassLoader urlClassLoader =…
RuntimeError
  • 1,332
  • 4
  • 23
  • 41
6
votes
1 answer

ClassNotFoundException with URLClassLoader in classes.jar (java.net package)

On Eclipse Galileo, got the following ClassNotFoundException when doing Debug As/Web Application. But works just fine when doing Run As/Web Application. I was given message that "The source attachment does not contain the source for the file…
tom
  • 14,273
  • 19
  • 65
  • 124
5
votes
2 answers

Load classes from folder without specifying the package

I have an application that allows, using an abstract class, people to write their own implementations. I load these implementations as .class-files from a directory. Currently, I have this solution: File classDir = new…
F.P
  • 17,421
  • 34
  • 123
  • 189
1
2 3
19 20