0

i've stucked with a big problem that's after make sure that there is no bug in all the files and when i run the JavaFX Application i get a small window contains"Exception While Running Application". The output highlights that the problem is in the Main Class so this is what i have in the Main class:

      package amnet23;

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

     public class AmNet23 extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("WorkSpace.fxml"));

        Scene scene = new Scene(root);

        stage.setScene(scene);
        stage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}
here's the Controller class:

    package amnet23;


import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Cursor;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javax.swing.text.html.HTMLEditorKit;

/**
 *
 * @author Ahmed
 */
public class FXMLDocumentController implements Initializable {
    Stage tt;
    //anchor
    AnchorPane ancpa;
   //labels fxid
    Label labeln1;
    Label labeln2;
    Label labelslo; // text field
    Button labelsear; // help
    Button labelpop; // about
    Label labeloren; // nejma
    Label labelpros; // search
    Label labelno;
   // text field
    TextField text11;
   //buttons fxid 
    //button links
    Button but1;
    Button but2;
    Button but3;
    Button but4;
    Button but5;
    Button but6;
    Button but7;
    Button but8;
    Button but9;
    Button but10;
    Button but11;
    Button but12;
    Button but13;
    Button but14;
    Button but15;
    Button but16;
    // other buttons
    Button butser;
    Button butnext;
    Button butprev;
    Button butref;
    Button buth;
    Button butg;
    Button but1f;
    Button butnej;
    Button butab;
   // tabpanes
    TabPane tabpane1;
    Tab tab1;
    Tab tab2;
    Tab tab3;
    Tab tab4;
    Tab tab5;
    Tab tab6;
    Tab tab7;
    Tab tab8;
    Tab tab9;
   // wabpanes
    WebView web1;
    WebView web2;
    WebView web3;
    WebView web4;
    WebView web5;
    WebView web6;
    WebView web7;
    WebView web8;
    WebView web9;
    //other window (chooser)
    @FXML
    Label que;
    @FXML
    Button tab1b;
     Button tab2b;
     Button tab3b;
     Button tab4b;
     Button tab5b;
     Button tab6b;
     Button tab7b;
     Button tab8b;
     Button tab9b;
    @FXML
    AnchorPane panoo;
@FXML
     private void  searchButton (ActionEvent evt) throws IOException {

       Stage stage = new Stage();
             Parent root = FXMLLoader.load(getClass().getResource("Choose.fxml"));
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.show();

         text11.setOnKeyTyped(new EventHandler<KeyEvent>(){
             public void hendeller (KeyEvent evty) throws IOException{
                 if (evty.getCode() == KeyCode.ENTER){
         Stage stage = new Stage();
          Parent root = FXMLLoader.load(getClass().getResource("Choose.fxml"));
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.show();
                 }
             }

             @Override
             public void handle(KeyEvent t)  {

             }


         });
     }
    @FXML
    private void tabfirst (ActionEvent ee) throws IOException { // for tha Chooser frame text.

                String hh = text11.getText();
                Socket socket = new Socket();

        try {
              web1.setVisible(true);
            //open cursor
            panoo.setCursor(Cursor.WAIT);
            que.setCursor(Cursor.WAIT);
            //add
            ancpa.setCursor(Cursor.WAIT);
            web1.setCursor(Cursor.WAIT);
            web2.setCursor(Cursor.WAIT);
            web3.setCursor(Cursor.WAIT);
            web4.setCursor(Cursor.WAIT);
            web5.setCursor(Cursor.WAIT);
            web6.setCursor(Cursor.WAIT);
            web7.setCursor(Cursor.WAIT);
            web8.setCursor(Cursor.WAIT);
            web9.setCursor(Cursor.WAIT);
            //do work
            URL url = new URL (hh);
            url.getContent();
            WebEngine myWebEngine = web1.getEngine();
            myWebEngine.load(url.toExternalForm());
            //close the window chooser
            Stage stage = new Stage();
              Parent root = FXMLLoader.load(getClass().getResource("Choose.fxml"));
              Scene scene = new Scene(root);
             stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                  @Override public void handle(WindowEvent t) { } });
            //close cursor
            ancpa.setCursor(Cursor.DEFAULT);
            web1.setCursor(Cursor.DEFAULT);
            web2.setCursor(Cursor.DEFAULT);
            web3.setCursor(Cursor.DEFAULT);
            web4.setCursor(Cursor.DEFAULT);
            web5.setCursor(Cursor.DEFAULT);
            web6.setCursor(Cursor.DEFAULT);
            web7.setCursor(Cursor.DEFAULT);
            web8.setCursor(Cursor.DEFAULT);
            web9.setCursor(Cursor.DEFAULT);
        }
       catch (IOException e){
           final  Stage stg = new Stage();           
            stg.initModality(Modality.APPLICATION_MODAL);
            stg.initOwner(stg);
            stg.setTitle("Cannot connect to the internet /n Please Verify your connection internet");
            labelno.setText("Cannot connect to the internet...");
            //close chooser
            Stage stage = new Stage();
             Parent root = FXMLLoader.load(getClass().getResource("Choose.fxml"));
             stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                  @Override public void handle(WindowEvent t) { } });

           //set cursor
             ancpa.setCursor(Cursor.DEFAULT);
            web1.setCursor(Cursor.DEFAULT);
            web2.setCursor(Cursor.DEFAULT);
            web3.setCursor(Cursor.DEFAULT);
            web4.setCursor(Cursor.DEFAULT);
            web5.setCursor(Cursor.DEFAULT);
            web6.setCursor(Cursor.DEFAULT);
            web7.setCursor(Cursor.DEFAULT);
            web8.setCursor(Cursor.DEFAULT);
            web9.setCursor(Cursor.DEFAULT);
       } finally{
           try{ socket.close(); } catch (Exception e){ }
           }

    }
    @FXML
    private void err (ActionEvent eer) {
              web1.setVisible(true);
              ancpa.setCursor(Cursor.WAIT);
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {

        }

}

And here is The StuckTrace :

ant -f C:\\Users\\Midoo\\Documents\\NetBeansProjects\\AmNet23 jfxsa-run
init:
Deleting: C:\Users\Midoo\Documents\NetBeansProjects\AmNet23\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\Midoo\Documents\NetBeansProjects\AmNet23\build\built-jar.properties
compile:
Detected JavaFX Ant API version 1.2
jfx-deployment:
jar:
Copying 12 files to C:\Users\Midoo\Documents\NetBeansProjects\AmNet23\dist\run1416917689
jfx-project-run:
Executing C:\Users\Midoo\Documents\NetBeansProjects\AmNet23\dist\run1416917689\AmNet23.jar using platform C:\Program Files\Java\jdk1.7.0_65\jre/bin/java
java.lang.IllegalAccessException: Class javafx.fxml.FXMLLoader$ValueElement can not access a member of class amnet23.FXMLDocumentController with modifiers ""
file:/C:/Users/Midoo/Documents/NetBeansProjects/AmNet23/dist/run1416917689/AmNet23.jar!/amnet23/WorkSpace.fxml:15
  at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:664)
  at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:575)
  at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2356)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2172)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2069)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2830)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2809)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2795)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2782)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2771)
  at amnet23.AmNet23.start(AmNet23.java:23)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
  at java.lang.Thread.run(Thread.java:745)

Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.javafx.main.Main.launchApp(Main.java:698)
    at com.javafx.main.Main.main(Main.java:871)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: Class javafx.fxml.FXMLLoader$ValueElement can not access a member of class amnet23.FXMLDocumentController with modifiers ""
    at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:664)
    at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:575)
    at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2356)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2172)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2069)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2830)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2809)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2795)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2782)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2771)
    at amnet23.AmNet23.start(AmNet23.java:23)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
    ... 1 more
Caused by: java.lang.IllegalAccessException: Class javafx.fxml.FXMLLoader$ValueElement can not access a member of class amnet23.FXMLDocumentController with modifiers ""
    at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
    at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261)
    at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253)
    at java.lang.reflect.Field.set(Field.java:738)
    at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:662)
    ... 21 more
Java Result: 1
Deleting directory C:\Users\Midoo\Documents\NetBeansProjects\AmNet23\dist\run1416917689
jfxsa-run:
BUILD SUCCESSFUL (total time: 6 seconds)

So idon't understand this problem caused by what please can anybody help me and Thanks in advance:)

4
  • Can you show the field declarations in the controller class and the corresponding FXML elements? Commented Jan 26, 2015 at 18:27
  • Sorry @James_D i don't understand you! Commented Jan 26, 2015 at 20:58
  • Which bit don't you understand? You have an FXML file, you have a controller class. Please update your question to show the fields you declare in the controller class. Please also show the corresponding elements in the FXML which are supposed to map to those fields. The error is generated when the FXMLLoader tries to initialize the controller fields: Class javafx.fxml.FXMLLoader$ValueElement can not access a member of class amnet23.FXMLDocumentController with modifiers "" Commented Jan 26, 2015 at 21:13
  • @James_D done ! i've edited Commented Jan 26, 2015 at 21:21

1 Answer 1

1

You haven't shown the FXML, so this is a bit of a guess, but most of the fields in your controller are not @FXML-annotated, and don't seem to be initialized elsewhere. So I suspect the FXMLLoader is trying to inject one (or more) of the fields that doesn't have an @FXML annotation. You need to annotate all the fields that are injected from the FXML file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.