1

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.

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();
        }
    }
}
  • 1
    This question appears to have nothing to do with `JavaFX`. Have you tried cleaning and rebuilding the project? – SedJ601 Mar 23 '21 at 04:36
  • I mentioned JavaFX because I am limited to using JavaFX with ver 1.8 for this particular class. Code snippets outside of this are useless to me. My problem is that I cannot clean and rebuild the project, I get stopped by this empty 'Browse JavaFX Application Classes' window. – Síofra Kelleher Mar 23 '21 at 17:44

2 Answers2

0

Try adding e.printStackTrace(); maybe you have No such file or directory

0

All What you need to do is extend your Main Class With "Application". Modify Your Main Class and main function Like This

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);
    }
}
SedJ601
  • 12,173
  • 3
  • 41
  • 59