So I'm trying to work on a project and can't get JavaFX to work through Eclipse to save my life. I've tried reconfiguring it, rebuilding the project, reinstalling eclipse and redownloading the JavaFX SDKs multiple times, added like 3 new user libraries of re-downloaded jar files, etc and keep getting the same error, even with the stock "Main" class that comes with the new project. I'm totally stumped. Here is the mess I am looking at:
Here is the code for my application that I am trying to test:
package application;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class StartupBrowser extends Application {
private BorderPane root;
private BorderPane browserContentHolder;
private WebView webView;
private WebEngine webEngine;
private HBox addressBar;
private HBox statusBar;
private Text domain;
private Text copyright;
private Text currentDate;
private Text currentTime;
private Text separator;
private final String homePage = "https://langara.ca";
private void setupAddressBar() {
addressBar = new HBox();
Button home = new Button("", new ImageView(new Image("home.png")));
TextField url = new TextField();
addressBar.getChildren().addAll(home, url);
}
private void setupStatusBar() {
statusBar = new HBox();
domain = new Text("langara.ca");
separator = new Text("|");
separator.setStyle("-fx-padding: 0 5 0 5;");
currentDate = new Text();
currentDate.setStyle("-fx-padding: 0 5 0 5;");
currentTime = new Text();
currentTime.setStyle("-fx-padding: 0 5 0 5;");
updateDateTime();
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("EEE, MMM dd, yyyy");
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("hh:mm:ss a");
currentDate.setText(dateFormatter.format(LocalDateTime.now()));
currentTime.setText(timeFormatter.format(LocalDateTime.now()));
copyright = new Text("JavaFX -- All Rights Reserved.");
statusBar.getChildren().addAll(domain, separator, currentDate, currentTime, separator, copyright);
statusBar.setAlignment(Pos.CENTER_RIGHT);
}
private void updateDateTime() {
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("hh:mm:ss a");
currentTime.setText(timeFormatter.format(LocalDateTime.now()));
}
private void setupBrowserContentHolder() {
browserContentHolder = new BorderPane();
webView = new WebView();
webEngine = webView.getEngine();
webEngine.load(homePage);
browserContentHolder.setCenter(webView);
}
public void start(Stage stage) {
root = new BorderPane();
this.setupAddressBar();
this.setupBrowserContentHolder();
this.setupStatusBar();
root.setTop(addressBar);
root.setBottom(statusBar);
root.setCenter(browserContentHolder);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setWidth(1200);
stage.setHeight(1000);
stage.setResizable(false);
stage.setTitle("JavaFX Browser");
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
and the error:
Error: Could not find or load main class application.StartupBrowser
Caused by: java.lang.ClassNotFoundException: application.StartupBrowser
And project structure:
As you can see it's a mess from me trying to redo the user libraries so many times. How do I get this to quit throwing this error so I can finally test my project?