问题标签 [urlclassloader]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - 从 URLClassLoader 将类保存到文件?并反编译它?
可以将 URLClassLoader 中的类保存到普通的 file.class 吗?然后反编译?
我尝试将其保存为对象
但是那行不通。
那么...如何反编译呢?我需要得到类似 jd-gui 的结果,但使用来自 URLClassLoader 的类。
scala - 如何在 Scala 中使用 ClassLoaders 为对象创建内存沙箱?
我正在尝试创建一组动态加载的 Scala 类(和对象),由 ClassLoader 保存在“沙箱”中(所有内存、资源、线程等都保存在沙箱中)。刷新时,我希望删除类加载器中保存的所有内存/静态对象。具体来说,我不希望有任何 Scala 对象。
我认为下面的代码应该这样做,但是刷新后它没有成功重新加载对象。
(包装工人)
(包主)
android - URLClassLoader 适用于 Java 但不适用于 Android
我的 URLClassLoader 实现似乎只适用于 pc,但不适用于 Android。
它工作得很好,但在android上我得到了
java.lang.ClassNotFoundException: MyClass
已设置 Internet 权限。
有谁知道我怎样才能让它工作?
java - Android 类加载器错误
我想在我的 jar 文件中实例化 ScreenX 类并尝试此站点上的所有 solition,但它无法运行。
我有两个文件;
我尝试了闲置代码。
这是我的 plugin.jar 的 ScreenX 类的代码。
package com.example.plugins;
有工作样本吗?请帮忙...
java - Java:URLClassLoader 将加载的类保存在 Temp 目录中
我正在尝试使用从 web 加载 jar 文件URLClassLoader
,一切正常,但所有加载的类都保存在 Windows 临时目录中,并且可以复制以进行反混淆,直到我调用classLoader.close();
这反过来会导致程序ClassNotFoundException
。
我可以加载类而不保存到磁盘吗?
(仅记忆)另一种解决方案加密 jar 类,并编写将解密类的自定义ClassLoader,但我没有找到任何示例。
我试图寻找有关此主题的文档或文章,但一无所获:(
请告诉我是否可以实施以及我可以在哪里获取有关该主题的材料?谢谢!
java - 由 URLClassLoader 加载的 JSF 托管 Bean
我正在尝试开发一个在运行时从 JAR 文件加载类的应用程序。有没有办法将该类注册为托管 Bean?
java - 使用 ClassLoader 加载内部类
我正在编写一个程序,它允许用户在文本区域中键入 java 代码,然后对其进行编译并将其作为一种“插件”加载到程序中。我目前能够编译 .java 文件并加载外部类,但我无法毫无错误地加载/实例化用户编写的内部类。目前这是我用来加载外部类的东西,这段代码可以工作,我可以轻松地使用外部类而没有任何复杂性。(我做了一些编辑以提高可读性,如果您发现错字告诉我)
原始文件名列表是从 GUI 发送的,其中列出了插件目录中的每个 .class 文件。他们的用户选择他们想要加载的类,单击一个按钮并将这些文件名发送到这些方法。在这段代码中,EventHandler 是一个类,您将在下面看到,InterfaceInnerClass 只是一个用作标记以确保没有任何严重问题的接口,而 CmdEvents 是我的程序中用于管理这些“插件”类的控制台命令。就像我上面说的,这段代码适用于外部类,问题是当我尝试加载内部类时。我的 EventHandler 抽象类的代码如下。
我的程序的工作方式是,它从用户那里接收一个字符串,然后调用条件(字符串),如果它返回真,它就调用执行(字符串)。我写了一些测试代码来试用我的加载器,如下所示。
我运行我的程序,同时选择 Test_Handler.class 和 Test_Handler$TestInner.class,然后单击按钮。当该方法返回一个 ArrayList 或成功加载的类时,它同时返回外部类和内部类。但是,当我运行程序并将“testinput”传递给条件和执行方法时,这是我的输出。
测试...线程“Execute_Thread_Test_Handler”中的异常 java.lang.NoClassDefFoundError: plugins/event_handlers/Test_Handler$TestInner at plugins.event_handlers.Test_Handler.execute(Test_Handler.java:11) at events.ThreadEventExecutor.run(ThreadEventExecutor.java:20 ) 引起:java.lang.ClassNotFoundException: plugins.event_handlers.Test_Handler$TestInner at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController。 doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 2 更多
我想要它打印的是
测试......内部工作!内部类已经测试了它是否有效?
所以最后我的问题是,我如何使上面的代码工作?我不想让我的用户编写自己的类加载器等来加载内部/单独的类(因为并非我的所有用户都一定会在编码方面表现出色)所以我需要能够在没有引用的情况下引用内部类类型代码爆炸。
java - 类路径选项与 URLClassLoader 或 Spring 噩梦
我有代码(它是另一个应用程序的包装器):
urls--包含应用程序的所有 jars。一些 jars 包含用于单例初始化的 spring 上下文。它是 3d 方代码。如果我从 cdm 执行我的包装器代码,例如: java -jar MyJar.jar application failed with classnotfoundexception(如果我从 cdm 执行包装器代码,Spring 无法从 classLoader 中的 jar 中找到类: java -cp %CLASSES%-jar MyJar.jar
其中 %CLASSES% 包含与类加载器应用程序工作的 url 相同的 jar,没有任何问题
java - URLClassLoader keeps throwing ClassNotFoundException. What am I doing wrong?
I'm working on a university java project that requires me to implement a simple plugin architecture. A main application in Project A would have to load plugins from a specified directory located in another project B. After having done some research on the topic (including stackoverflow), I decided to go with URLClassLoader to load the classes which I might then instatiate. Project B references Project A and all plugins extend a common plugin class (might as well be an interface but should not make any difference). This is what I have got so far:
The source for the plugin class I try to load:
and the code that is supposed to load the class:
Now I always end up with a ClassNotFoundException:
java.lang.ClassNotFoundException: plugin.Circle at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at de.uks.student.pluginpattern.model.EditorSystem.init(EditorSystem.java:412) at de.uks.student.pluginpattern.EditorSystem.main(EditorSystem.java:13)
I've already checked that
- the generated URL can be correctly resolved by any web browser and Windows Explorer.
- Circle.class has been built and is present in the directory referenced by the used URL
- className resolves to "plugin.Circle" which should be the correct binary name to use
- removing inheritance from plugin.Circle does not make any difference.
I've pretty much run out of ideas on what else to try. What am I doing wrong?
java - 如何使用 Java UrlClassLoader 重新加载类
我有一个在程序执行期间需要多次使用的类列表,我需要动态加载它们,因为它们的代码可能会经常更改,我想将它们视为服务,以便我可以轻松更新它们。这是我的问题:
即使没有更改,UrlClassLoader 是否总是再次加载该类?这会导致性能或内存问题吗?
这是我的测试代码:
}
我希望你能帮助我,谢谢。