1

I am currently trying to create a javafx application and I keep on getting errors when I try to compile the automatically generated code when I am in Intelli IDEA. I am also running JDK 11 currently.

here are the errors that I am getting when building:

 Error:(3, 26) java: package javafx.application does not exist
 Error:(4, 19) java: package javafx.fxml does not exist
 Error:(5, 20) java: package javafx.scene does not exist
 Error:(6, 20) java: package javafx.scene does not exist
 Error:(7, 20) java: package javafx.stage does not exist 
 Error:(9, 27) java: cannot find symbol
                 symbol: class Application
 Error:(12, 23) java: cannot find symbol
                   symbol:   class Stage
                   location: class sample.Main
 Error:(11, 5) java: method does not override or implement a method from a supertype
 Error:(13, 9) java: cannot find symbol
                 symbol:   class Parent
                 location: class sample.Main
 Error:(13, 23) java: cannot find symbol
                  symbol:   variable FXMLLoader
                  location: class sample.Main
 Error:(13, 39) java: cannot find symbol
                  symbol:   method getClass()
                  location: class sample.Main
 Error:(15, 35) java: cannot find symbol
                  symbol:   class Scene
                  location: class sample.Main
 Error:(21, 9) java: cannot find symbol
                  symbol:   method launch(java.lang.String[])
                  location: class sample.Main

here is my code

Main.java:

 package sample;

 import javafx.application.Application;
 import javafx.fxml.FXMLLoader;
 import javafx.scene.Parent;
 import javafx.scene.Scene;
 import javafx.stage.Stage;

 public class Main extends Application {

@Override
public void start(Stage primaryStage) throws Exception{
    Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Hello World");
    primaryStage.setScene(new Scene(root, 300, 275));
    primaryStage.show();
}


public static void main(String[] args) {
    launch(args);
   }
 }

Controller.java:

 package sample;

 public class Controller {
 }

sample.fxml:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?scenebuilder-background-color 0xdae5ffff?>

  <AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" 
minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" 
prefWidth="600.0" 
xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
<children>
    <ComboBox fx:id="trans_cb" blendMode="SRC_OVER" cache="false" 
disable="false" editable="false" layoutX="27.0" layoutY="47.0" 
mouseTransparent="false" prefHeight="21.000099999997474" prefWidth="150.0" 
promptText="SELECT">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="i1" />
                <String fx:value="i2" />
                <String fx:value="i3" />
            </FXCollections>
        </items>
    </ComboBox>
     <Button layoutX="27.0" layoutY="139.0" mnemonicParsing="false" 
text="Generate" />
    <TextField layoutX="83.0" layoutY="14.0" prefWidth="71.0" />
    <TextField layoutX="208.0" layoutY="14.0" prefWidth="71.0" />
    <Label layoutX="27.0" layoutY="17.0" text="Channel" />
    <Label layoutX="169.0" layoutY="17.0" text="TPO" />
    <Label layoutX="284.0" layoutY="17.0" text="KW" />
    <CheckBox layoutX="192.0" layoutY="50.0" mnemonicParsing="false" 
text="Exciter" />
    <ComboBox layoutX="284.0" layoutY="48.0" prefHeight="21.0" 
prefWidth="125.0" promptText="Aux">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
            </FXCollections>
        </items>
    </ComboBox>
    <ComboBox layoutX="285.0" layoutY="77.0" prefHeight="21.0" 
prefWidth="124.0">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
            </FXCollections>
        </items>
    </ComboBox>
    <ComboBox layoutX="27.0" layoutY="78.0" prefHeight="21.0" 
prefWidth="150.0">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
            </FXCollections>
        </items>
    </ComboBox>
    <ComboBox layoutX="192.0" layoutY="79.0">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
            </FXCollections>
        </items>
    </ComboBox>
    <ComboBox layoutX="27.0" layoutY="108.0" prefHeight="21.0" 
prefWidth="150.0">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
            </FXCollections>
        </items>
    </ComboBox>
    <ComboBox layoutX="192.0" layoutY="108.0">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
            </FXCollections>
        </items>
    </ComboBox>
    <ComboBox layoutX="285.0" layoutY="108.0" prefHeight="21.0" 
prefWidth="124.0">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="Item 1" />
                <String fx:value="Item 2" />
                <String fx:value="Item 3" />
            </FXCollections>
        </items>
    </ComboBox>
</children>
</AnchorPane>
twjohn
  • 33
  • 4
  • JavaFX is no longer shipped with the JDK for Java 11+. Have you brought in the appropriate dependencies? – Slaw Oct 19 '18 at 09:47
  • Your `FXMl` does not appear to point to its controller. – SedJ601 Oct 19 '18 at 13:59
  • `fx:controller="com.example.MyController"` https://stackoverflow.com/questions/33881046/how-to-connect-fx-controller-with-main-app – SedJ601 Oct 19 '18 at 14:00
  • @Slaw I don't think that I have done that, what are the dependencies that I would need? – twjohn Oct 19 '18 at 15:30
  • @Slaw all of the imported libraries seem to be working now. Now i'm getting one error thats saying could not find or load main class – twjohn Oct 19 '18 at 16:32

0 Answers0