चलाए गए प्रत्येक जावाएफएक्स एप्लिकेशन में मैंने दो NullPointerExceptions को फेंक दिया है। वे परियोजनाओं के निष्पादन को रोकते या प्रभावित नहीं करते हैं, और मैं केवल उन्हें देख सकता हूं यदि मैं अपने अनुप्रयोग डीबग मोड में चलाता हूं। पहली त्रुटि के स्टैक ट्रेस हैजावाएफएक्स अनुप्रयोगों ने NullPointerExceptions को फेंक दिया लेकिन फिर भी
public class JavaFXTSample extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
StackPane iAmRoot = new StackPane();
Scene scene = new Scene(iAmRoot, 300, 250);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main (String[] args) {
launch(args);
}
}
यहाँ: मैं भी ओरेकल से HelloWorld नमूना के साथ इस मुद्दे हैं और इस न्यूनतम कार्यक्रम आ रही
Thread [main] (Suspended (exception NullPointerException))
SystemProperties.setVersions() line: 81 [local variables unavailable]
SystemProperties.lambda$static$28() line: 67
30621981.run() line: not available
AccessController.doPrivileged(PrivilegedAction<T>) line: not available [native method]
SystemProperties.<clinit>() line: 64
LauncherImpl.startToolkit() line: 668
LauncherImpl.launchApplicationWithArgs(String, String, String[]) line: 337
LauncherImpl.launchApplication(String, String, String[]) line: 328
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
LauncherHelper$FXHelper.main(String...) line: not available
और यहाँ पीछे नहीं है:
Thread [JavaFX Application Thread] (Suspended (exception NullPointerException))
PropertyHelper.lambda$getBooleanProperty$514(String) line: 39
7164036.run() line: not available
AccessController.doPrivileged(PrivilegedAction<T>) line: not available [native method]
PropertyHelper.getBooleanProperty(String) line: 37
Parent.<clinit>() line: 87
JavaFXTSample.start(Stage) line: 16
LauncherImpl.lambda$launchApplication1$162(AtomicBoolean, Application) line: 863
2266602.run() line: not available
PlatformImpl.lambda$runAndWait$175(Runnable, CountDownLatch) line: 326
32251660.run() line: not available
PlatformImpl.lambda$null$173(Runnable) line: 295
11305869.run() line: not available
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
PlatformImpl.lambda$runLater$174(Runnable, AccessControlContext) line: 294
30052382.run() line: not available
InvokeLaterDispatcher$Future.run() line: 95
WinApplication._runLoop(Runnable) line: not available [native method]
WinApplication.lambda$null$148(int, Runnable) line: 191
32126786.run() line: not available
Thread.run() line: not available
इतना ही नहीं, अगर मैं की iAmRoot
और scene
(ताकि start()
सिर्फ पढ़ता primaryStage.show();
) किसी भी घटना को हटाने, दूसरा त्रुटि नहीं होती है। ये क्यों हो रहा है?
मैं इस प्रश्न को (JavaFX application throws NullPointerException at startup) से पहले ढूंढने में सक्षम हूं, लेकिन किसी ने इसे हल नहीं किया है, और यह 2 साल पहले पूछा गया था।
यदि यह मदद करता है, तो मैं विंडोज 7 प्रोफेशनल पर ग्रहण 4.5.2 चला रहा हूं, और मुझे नहीं लगता कि मैं बिल्कुल FXML का उपयोग कर रहा हूं।
संपादित करें:
क्या इसके लायक है के लिए, मैं दूसरी त्रुटि के लिए स्रोत कोड नहीं मिल सकता है, लेकिन मैं विधि है जो पहले त्रुटि फेंकता है (लाइन 81) के लिए JavaFX के कोड मिला:
58 private static final String versionResourceName =
59 "/com/sun/javafx/runtime/resources/version.properties";
...
78 private static void setVersions() {
79 int size;
80 InputStream is =
81 SystemProperties.class.getResourceAsStream(versionResourceName);
82 try {
83 size = is.available();
84
85 byte[] b = new byte[size];
86 int n = is.read(b);
87 String inStr = new String(b, "utf-8");
88 SystemProperties.setFXProperty("javafx.version",
89 getValue(inStr, "release="));
90
91 SystemProperties.setFXProperty("javafx.runtime.version",
92 getValue(inStr, "full="));
93
94 } catch (Exception ignore) {
95 }
96 }
यह अभी वापस है। लेकिन यह अभी भी छवियों के रूप में पोस्ट किया गया है, जो पढ़ने के लिए वास्तव में मुश्किल हैं ... "थ्रेड [मुख्य] (निलंबित ...)" अजीब है। क्या आप इसे डीबग मोड में चला रहे हैं? –
मैंने इसे कोड के रूप में दोबारा सुधार दिया, और मैं इसे डीबग में चला रहा हूं। इन त्रुटियों को बिल्कुल संभाला नहीं जाता है, और वे कोड को प्रभावित नहीं करते हैं, इसलिए उन्हें देखने का एकमात्र तरीका डीबग मोड में चलाना है। –
तो यदि आप इसे सामान्य रूप से चलाते हैं, तो वे कंसोल में नहीं दिखते हैं? –