简体   繁体   English

如何设置NetBeans以使用特定命令运行Java应用程序(或使用其他JRE)?

[英]How to setup NetBeans to run java application with specific command (or use other JRE)?

The problem occurs when launching an application which loads a DLL. 启动加载DLL的应用程序时会发生此问题。 I'm doing it with System.load("C:\\fullpath\\test.dll") . 我正在使用System.load("C:\\fullpath\\test.dll") The project compiles with no errors, creates a jarfile Test.jar but when I run it with NetBeans it throws an exception 该项目编译没有错误,创建了一个jarfile Test.jar,但是当我使用NetBeans运行它时会抛出异常

Exception in thread "main" 线程“主”中的异常

java.lang.UnsatisfiedLinkError: C:\\fullpath\\test.dll: Can't find dependent libraries java.lang.UnsatisfiedLinkError:C:\\ fullpath \\ test.dll:找不到依赖库

However if I run exactly the same code on Eclipse it runs fine. 但是,如果我在Eclipse上运行完全相同的代码,它将运行良好。 What I've found out that it's most probably a java bug because when running from command line gives such results: 我发现这很可能是Java错误,因为从命令行运行时会产生以下结果:

"C:\\Program Files (x86)\\Java\\jre7\\bin\\java.exe" -jar test.jar | “ C:\\ Program Files(x86)\\ Java \\ jre7 \\ bin \\ java.exe” -jar test.jar | Runs fine 运行良好

"C:\\Program Files (x86)\\Java\\jdk1.7.0_01\\jre\\bin\\java.exe" -jar test.jar | “ C:\\ Program Files(x86)\\ Java \\ jdk1.7.0_01 \\ jre \\ bin \\ java.exe” -jar test.jar | Runs fine 运行良好

"C:\\Program Files (x86)\\Java\\jdk1.7.0_01\\bin\\java.exe" -jar test.jar | “ C:\\ Program Files(x86)\\ Java \\ jdk1.7.0_01 \\ bin \\ java.exe” -jar test.jar | Throws an exception 引发异常

And as I understand NetBeans runs the last command and therefore throws an exception. 据我了解,NetBeans运行最后一条命令,因此引发异常。 I tried searching on how to add a custom command or how to bind jre instead of jdk but with no success. 我尝试搜索如何添加自定义命令或如何绑定jre而不是jdk,但是没有成功。

I don't know if it helps but... in menu Tools -> Java Platforms You can manage Java Platforms. 我不知道是否有帮助,但是...在菜单工具-> Java平台中,您可以管理Java平台。 Here You can specify other JDKs that You might use in future. 在这里,您可以指定将来可能使用的其他JDK。

Then, in project's Properties window, You choose Libraries section and there You can choose Java Platform to use in project. 然后,在项目的“属性”窗口中,选择“库”部分,然后在此处选择要在项目中使用的Java平台。 I think it's the thing You are looking for, but if not - sorry for misunderstanding. 我认为这是您要寻找的东西,但如果没有,对不起您的误会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM