classloader

Load my own Xalan implementation where an older Xalan is loaded to the parent classloader

元气小坏坏 提交于 2019-12-02 10:11:32
I'm writing a plugin for a framework that loads my code as a child classloader The problem is that that framework uses a certain Xerces version, that is not compatible with my code, I want to use my "own" jar for xerces, but it seems since the old one was already loaded, I can't seem to make my code use mine. I'm looking for some classloader seperation, I know it's a know problem, but can't seem to solve it Is there any framework, library, or code sample to user locally a newer jar in such a scenario? Have you tried loading the classes of your framework and Xerces libs as a part of the

Get intent Class loader . I want to set text a textView in secondActivity to name of firstActivity (Actually I need class loader name)

拟墨画扇 提交于 2019-12-02 10:10:10
In going from an activity to another one by an intent, How can I get class loader name ? I need name of class loader. If my intention wasn't clear, Please look at this codes. I created a test app for this Question. It has three activity. ActivityA , ActivityB and ActivityC. I have a button in ActivityA and ActivityB that start activityC. ActivityA: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_a); Button btnGoFromActivityAToActivityC = (Button) findViewById(R.id.btnGoFromActivityAToActivityC); btnGoFromActivityAToActivityC

Load jar dynamically

浪尽此生 提交于 2019-12-02 10:01:59
In my java application, I read a jar file (packaged with Maven shade plugin) into a bytestream. In the jar there is a entrypoint class defined in POM.xml <build> ... <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.mycompany.TheEntryPoint</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> How do I load such class into my java app dynamically? Update: The jar is loaded as byte stream and does not reside in the file system or URL The easiest way to do

War deployment error related to classloading

若如初见. 提交于 2019-12-02 10:00:38
问题 when i am deploying my war file and run it it will give error like org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader Jan 6, 2011 3:16:04 PM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor servlet.xml Jan 6, 2011 3:16:04 PM org.apache.catalina.core.StandardContext preDeregister SEVERE: error stopping LifecycleException: Pipeline has not been started at org.apache.catalina.core.StandardPipeline.stop

When does Class#getClassLoader return null?

拈花ヽ惹草 提交于 2019-12-02 08:10:52
Say I have some Java code: public class Widget { ...whatever } And some code that classloads the Widget : ClassLoader widgetLoader = Widget.class.getClassLoader(); Can widgetLoader ever be null ? Why/why not? If so, under what circumstances? According to this method javadoc : Returns the class loader for the class. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader. 来源: https://stackoverflow.com/questions/17723303/when-does-classgetclassloader-return-null

loading BufferedImage with ClassLoader.getResource()

南笙酒味 提交于 2019-12-02 07:35:23
I am trying to load an image file (gif) which is stored locally in the same directory as my Eclipse java project: ref is the relative path where the gif image is stored. public Sprite getSprite(String ref) { BufferedImage sourceImage = null; try { URL url = this.getClass().getClassLoader().getResource(ref); if (url == null) { fail("Can't find ref: "+ref); } sourceImage = ImageIO.read(url); } catch (IOException e) { fail("Failed to load: "+ref); } } The client code that uses the above method is: public Entity(String ref,int x,int y) { this.sprite = ResourceManager.getSprite("sprites/alien.gif")

Android's basic components' class loading & _java objects_ lifecycle

无人久伴 提交于 2019-12-02 07:26:41
While there are countless resources on Application, Activity etc lifecycle seen from an API perspective ( onCreate/Destroy/Whatnot() methods) there is scarcely any information on the actual object's lifecycle for these components from the Java perspective . So for instance I saw (on a YouTube marakana video) that services are basically singletons - and this left me wondering on the state of an IntentService - can it be shared ? Or is this a singleton too ? I guess initially a process is created (by Zygote ?), along with a DalvikVM instance and then the classes for all components that are

Does Java Class Linkage Resolution step OR Initialisation lead to loading of other resolved classes?

人盡茶涼 提交于 2019-12-02 06:41:56
I was going through the JVM specification document and JLS , on the classloading mechanism in java . Here is what I understand . At first the when the main class is being asked to be loaded , it looks if the binary representation of the class has been already loaded or not , if not the class loader loads the class file from the disk . Linkage Steps: Verification ,Preparation and Resolution Initialisation. What I find confounding is , while in the Resolution and Initialisation steps if a class is referenced which has yet not been loaded from the source , what happens ? does the Resolution or

How to include two different versions of the same dependency?

穿精又带淫゛_ 提交于 2019-12-02 05:33:09
问题 I am working on a customization for an ERP system in Java. In my customization I want to use Apache POI 3.10.1. Therefore I have integrated the jars poi-3.10.1-20140818.jar and poi-ooxml-3.10.1-20140818.jar. However, these jars contains several classes that are already included in the core code of the ERP System, but have differences. If the core ERP classes override the POI classes, the customization throws a Runtime exception. Possibly the same will happens with a core functionality if the

关于Java对相对目录的文件读写和调用方法的一些总结

Deadly 提交于 2019-12-02 04:47:46
关于 Java 对相对目录的文件读写和调用方法的一些总结 首先要讲 Java 路径 Java 中使用的路径,分为两种:绝对路径和相对路径。具体而言,又分为四种: 1. 本地系统的绝对路径: 如: windows: C:\abc\ projectName\bin\def. properties Linux: /us/home/name/projectName/bin/def.properties Java.io 包中的类,需要使用这种形式的参数。但是,它们一般也提供了 URI 类型的参数,而 URI 类型的参数,接受的是 URI 样式的 String 。因此,通过 URI 转换,还是可以把 URI 样式的绝对路径用在 java.io 包中的类中。 2.URI 形式的绝对资源路径 如: file:/C:/abc/def.properties URL 是 URI 的特例。 URL 的前缀 / 协议,必须是 Java 熟悉的。 URL 可以打开资源,而 URI 则不行。 URL 和 URI 对象可以互相转换,使用各自的 toURI(),toURL() 方法即可! 3. 相对于 classpath 的相对路径 如:相对于 file:/C:/abc/projectName/bin/def. properties/ 这个路径的相对路径。其中, bin 是本项目的 classpath 。所有的