Questions tagged [classloader]

A class loader is an object that is responsible for loading classes in Java.

A class loader is an object that is responsible for loading classes in Java.

Given the binary name of a class, a class loader should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system. A class loader may also chose to delegate to another class loader. It may do this before or after doing a normal lookup.

Every Class object contains a reference to the class loader that defined it. This class loader is used by the runtime for linking to other classes referenced by this class. Together with the name of the class the defining class loader uniquely identifies a class. It's therefore possible to have several classes in with the same name in Java as long as they have a different defining class loader.

4126 questions
2
votes
0 answers

Loading weblogic.jar (of Weblogic 12c Server) with URLClassLoader

I try to load the weblogic.jar of the weblogic server (12.1.3) into the classpath dynamically, e.g. via an UrlClassloader during runtime. Then I want to use this classloader to load and start the emebedded weblogic server via reflection (the reason…
jric
  • 21
  • 4
2
votes
1 answer

Class loading issues with BIRT

We bundle the BIRT runtime with our application(EAR file) and everything was fine with version 2.2 which we were using until recently. However when we upgraded to BIRT 2.5.1 we are running into class loading issues. The BIRT runtime packages a…
KRR
  • 21
  • 4
2
votes
2 answers

Conflicts between JDK6 and xml-apis

After upgrading OpenSAML from 1.1 to 2.6.1, which needs xerces-impl dependency, the following stack appears on startup : Caused by: java.lang.ClassCastException: org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl cannot be cast to…
Johann Goulley
  • 405
  • 14
  • 25
2
votes
2 answers

How to run a java class from a jar file dynamically

I'm working on a java project that needs a third-party java program running as a server to work. Normally, I'd do: java -cp jarfile1.jar:jarfile2.jar className arg1 arg2 And then I'd run my java code. This way it works. I'd like to know if there is…
2
votes
1 answer

Using class loader to enable shared code between Java and Android

I am trying to build an application that runs under JavaSE and Android. Most of the code is the same between the two, but there are some specific functions that need to be separated. I use Eclipse. So I decided to put the shared code in a separate…
Branex
  • 362
  • 1
  • 6
  • 14
2
votes
2 answers

Reading an EAR's manifest

I need to load the manifest of an application I am deploying on Glassfish as an EAR. All the info I've found on internet is regarding reading manifests of jars or wars. I've tried to apply the snippets of code I've found to my problem but I've not…
Pedro Otero
  • 324
  • 5
  • 15
2
votes
2 answers

Are static initializers with references to other jars a bad design decision?

A few days ago, I've tried to solve this SO-Question. I know about static initializers and there benefits in java. But due to the problem I was thinking if they could be the wrong design decision if they reference a class outside of the jar. What…
Martin Baumgartner
  • 3,524
  • 3
  • 20
  • 31
2
votes
0 answers

How to load jar classes as if they were referenced library?

I loaded my jar classes with: ClassLoader.getSystemClassLoader().loadClass(name) in my Plugin loader. But it seems JVM does not register them as a class as if they were referenced, therefore they get garbage collected I get: ClassNotFoundException…
armin
  • 1,985
  • 6
  • 38
  • 52
2
votes
1 answer

Java Applet - Cannot inherit from final class

We have a java applet which is working OK in most client environments, primarily Windows 7, but recently we have been asked to support Ubuntu clients as well. The problem is that when the applet is fired up on the Ubuntu client (running Firefox and…
harmic
  • 28,606
  • 5
  • 67
  • 91
2
votes
1 answer

Replace the class of a field at runtime (for protostuff)

I'm working on a framework for backwards compatiblity between different versions of a class (from serialized binary representations). One thing I'm stuck on is how to replace a field used in a class with a different version of the field's class - at…
user2323596
  • 523
  • 1
  • 6
  • 11
2
votes
1 answer

JBoss - different class loading system in the same application - possible?

I looked at this article that talks about JBoss class-loading, but still got scenario that I'd like to verify: in case I have got a utility class that is located both in the application's archive (myApp/WEB-INF/lib) and in the server/default/lib…
Spiderman
  • 9,602
  • 13
  • 48
  • 56
2
votes
1 answer

Does the default classloader in java keep everything in memory or leave in file system?

I wonder when you have a jar, dynamically loaded in your running program, do all the content (classes, resources) in the jar be stored somewhere in the VM memory? So that everytime you need to access the class or a text resource file (e.g. via…
user1589188
  • 5,316
  • 17
  • 67
  • 130
2
votes
0 answers

Classloader issue in custom Jenkins plugin

We are developing a Jenkins plugin that communicate with Stash and also depends on the Jenkins git plugin. When navigating to one of the page exposed by our plugin, I have the following stacktrace: java.lang.LinkageError: loader constraint…
Guillaume
  • 18,494
  • 8
  • 53
  • 74
2
votes
1 answer

In which memory is saving Java ClassLoader instance

I want to know where the ClassLoader instance is saving, in which memory. Is it saving in heap or in permgen? And if I have a custom ClassLoader( for example JasperReports loads his own ClassLoader which calls JRClassLoader ), instance of it is…
Lyudvig
  • 87
  • 1
  • 2
  • 9
2
votes
1 answer

Creating a SimpleName to CanonicalName map statically

I need to create a map of our domain classes simple names to their fully canonical names. I want to do this only for classes that are under our package structure, and that implement Serializable. In serialization we use the canonical names of…
Groostav
  • 3,170
  • 1
  • 23
  • 27