gpt4 book ai didi

java - 在运行时加载类

转载 作者:行者123 更新时间:2023-12-02 08:13:24 24 4
gpt4 key购买 nike

我有一些在运行时加载类的代码:

Class.forName("oracle.jdbc.driver.OracleDriver");

但是这和 IKVM 似乎存在问题 - 我想知道是否有其他方法可以在我的 Java 程序中实现上述目标,或者是否有人知道为什么这可能会导致 ikvm 问题?

谢谢

抱歉 - 我不知道如何找到答案,我花了很长时间才走到这一步!这是在 Exception e catch 语句中捕获的,我很确定它是由上面发布的行抛出的

classname IKVM.NativeCode.java.lang.Class Filename null Method name forName0 Line number -1 classname java.lang.Class Filename Class.java Method name forName0 Line number -2 classname java.lang.Class Filename Class.java Method name forName Line number 287 classname Test Filename Test.java Method name init Line number 50 classname Test Filename Test.java Method name isPDFAvailable Line number 24 classname cli.Analytical_Report.Form1 Filename Form1.cs Method name hasGains Line number 296 classname cli.Analytical_Report.Form1 Filename Form1.cs Method name determineAvailableData Line number 209 classname cli.Analytical_Report.Form1 Filename Form1.cs Method name consumeFile Line number 71 classname cli.Analytical_Report.Form1 Filename Form1.cs Method name btnSelectFile_Click Line number 49 classname cli.System.Windows.Forms.Control Filename null Method name OnClick Line number -1 classname cli.System.Windows.Forms.Button Filename null Method name OnClick Line number -1 classname cli.System.Windows.Forms.Button Filename null Method name OnMouseUp Line number -1 classname cli.System.Windows.Forms.Control Filename null Method name WmMouseUp Line number -1 classname cli.System.Windows.Forms.Control Filename null Method name WndProc Line number -1 classname cli.System.Windows.Forms.ButtonBase Filename null Method name WndProc Line number -1 classname cli.System.Windows.Forms.Button Filename null Method name WndProc Line number -1 classname cli.System.Windows.Forms.Control$ControlNativeWindow Filename null Method name OnMessage Line number -1 classname cli.System.Windows.Forms.Control$ControlNativeWindow Filename null Method name WndProc Line number -1 classname cli.System.Windows.Forms.NativeWindow Filename null Method name DebuggableCallback Line number -1 classname cli.System.Windows.Forms.UnsafeNativeMethods Filename null Method name DispatchMessageW Line number -1 classname cli.System.Windows.Forms.Application$ComponentManager Filename null Method name System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop Line number -1 classname cli.System.Windows.Forms.Application$ThreadContext Filename null Method name RunMessageLoopInner Line number -1 classname cli.System.Windows.Forms.Application$ThreadContext Filename null Method name RunMessageLoop Line number -1 classname cli.System.Windows.Forms.Application Filename null Method name Run Line number -1 classname cli.Analytical_Report.Program Filename Program.cs Method name Main Line number 18 classname cli.System.AppDomain Filename null Method name _nExecuteAssembly Line number -1 classname cli.System.AppDomain Filename null Method name ExecuteAssembly Line number -1 classname cli.Microsoft.VisualStudio.HostingProcess.HostProc Filename null Method name RunUsersAssembly Line number -1

最佳答案

这是我第一次听说 ikvm,但我会尽力提供帮助。

首先,加载 JDBC 驱动程序的另一种方法是使用

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

无论如何,我在 ikvm 网站上读到,您必须使用命令 ikvmc 将 JAR 转换为 DLL。您是否已将 Oracle 驱动程序 JAR 转换为 DLL?并且:您确定已使该 JAR/DLL 中的类可供程序使用吗? (无论 Java 类路径有什么等价物)

希望有帮助!

关于java - 在运行时加载类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6933422/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com