[英]Netbeans cannot find JavaFX Application classes
I'm trying to run some code snippets from my Java class in netbeans, and netbeans consistently cannot seem to recognise the application classes(no matter the code snippet) and throws up an empty Browse JavaFX Application Classes window whenever I try to build or run the application. I'm trying to run some code snippets from my Java class in netbeans, and netbeans consistently cannot seem to recognise the application classes(no matter the code snippet) and throws up an empty Browse JavaFX Application Classes window whenever I try to build or run应用程序。
Here is the code I'm currently trying to run:这是我目前正在尝试运行的代码:
package examplereaderusingfilereader;
import java.io.Reader;
import java.io.FileReader;
public class ExampleReaderUsingFileReader {
public static void main(String[] args) {
//creates an array of character
char[] array = new char[100];
try {
//creates a reader using the FileReader
Reader input = new FileReader("input.txt");
//checks if reader is ready
System.out.println("Is there data in the stream? " + input.ready());
//Reads characters
input.read(array);
System.out.println("Data in the stream");
System.out.println(array);
//closes the reader
input.close();
} catch(Exception e) {
e.getStackTrace();
}
}
}
Try adding e.printStackTrace();
尝试添加
e.printStackTrace();
maybe you have No such file or directory也许你没有这样的文件或目录
All What you need to do is extend your Main Class With "Application".您需要做的就是使用“应用程序”扩展您的主 Class。 Modify Your Main Class and main function Like This
像这样修改你的主 Class 和主 function
public class ExampleReaderUsingFileReader extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
// Your snippet code here
Scene scene = new Scene(new AnchorPane());
//create your fxml file on the same folder of main if not exist
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.