来自java.lang.J9VMInternals的NullPointerException [英] NullPointerException from java.lang.J9VMInternals
问题描述
我正在尝试运行这个Qt Jambi Hello World示例的稍微修改版本,但是我遇到一个NullPointerException可触及我的第一行代码。唯一可能的办法是,如果QApplication为null,但它在我的构建路径,我的代码编译。
I'm trying to run a slightly modified version of this Qt Jambi Hello World example but I encounter a NullPointerException tracable to my very first line of code. The only way this would be possible would seem to be if QApplication is null, but it's on my build path, and my code compiles.
起初我想知道空指针是否缺少构造函数,但是添加一个仍然导致错误。现在我想知道是否因为可能有一些JNI(Java Native Access)在幕后进行,以使Qt Jambi正常工作,或者尽管编译(在Eclipse中),IDE仍然没有正确执行文件main方法。
At first I wondered if the null pointer was my lack of a constructor, but adding one still results in the error. Now I'm wondering if it's because there is probably some JNI (Java Native Access) going on behind the scenes to make Qt Jambi work, or if despite compiling (in Eclipse), the IDE is still not executing the file main method correctly.
这是适用于Windows 7上的Java 1.6
This is for Java 1.6 on Windows 7
POSTSCRIPT:
不知道使用NetBeans可以正常工作。感谢所有回答或评论的人。
POSTSCRIPT: Woudn't you know it works fine using NetBeans. Thanks to everybody who answered or commented.
代码:
import com.trolltech.qt.gui.*;
public class EcosDesk {
public static void main(String args[]) {
if(args == null) args = new String[0]; //suggested addition
QApplication.initialize(args);
QPushButton hello = new QPushButton("Hello World!");
hello.show();
QApplication.exec();
}
}
堆栈追踪:
Exception in thread "main" java.lang.NullPointerException
at java.lang.J9VMInternals$1.run(J9VMInternals.java:273)
at java.security.AccessController.doPrivileged(AccessController.java:202)
at java.lang.J9VMInternals.cloneThrowable(J9VMInternals.java:248)
at java.lang.J9VMInternals.copyThrowable(J9VMInternals.java:289)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:179)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at com.motion.ecos.EcosDesk.main(EcosDesk.java:7)
ECLIPSE的classpath.xml:
ECLIPSE'S classpath.xml:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="C:/Users/dp078008/Downloads/qtjambi-4.6.3-win32/qtjambi-4.6.3/qtjambi-4.6.3.jar"/>
<classpathentry kind="lib" path="C:/Users/dp078008/Downloads/qtjambi-4.6.3-win32/qtjambi-4.6.3/qtjambi-win32-msvc2005-4.6.3.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
推荐答案
可能是 args
实际上是 null
,因为您没有在Eclipse中运行配置中正确设置
It could be that args
is actually null
because you didn't set it up correctly in the run Configurations in Eclipse
这篇关于来自java.lang.J9VMInternals的NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!