Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1570 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  java.lang.reflect.InvocationTargetException dans un projet

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

java.lang.reflect.InvocationTargetException dans un projet

n°2329471
tryri
Rien est vrai. Tout est permis
Posté le 20-02-2019 à 18:59:14  profilanswer
 

Bonjour,  
Je travail sur un projet Java de Space Invaders sur Intellij Idea, j'utilise donc javafx pour cela et pendant la compilation l'exception java.lang.reflect.InvocationTargetException apparait, plus loin dans les logs la première erreur est signaler au niveau d'une simple instanciation d'un label.
Si vous savez pourquoi cette erreur apparait et comment la corriger je vous remercierai
 
Voici le log complet:

Code :
  1. Exception in Application start method
  2. java.lang.reflect.InvocationTargetException
  3. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  4. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  5. at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  6. at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  7. at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
  8. at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
  9. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  10. at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  11. at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  12. at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  13. at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
  14. Caused by: java.lang.RuntimeException: Exception in Application start method
  15. at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
  16. at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
  17. at java.base/java.lang.Thread.run(Thread.java:834)
  18. Caused by: java.lang.IllegalAccessError: class javafx.scene.control.Control (in unnamed module @0x6b99a314) cannot access class com.sun.javafx.application.PlatformImpl (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.application to unnamed module @0x6b99a314
  19. at javafx.scene.control.Control.<clinit>(Control.java:87)
  20. at Accueil.menu(Accueil.java:51)
  21. at Accueil.<init>(Accueil.java:20)
  22. at Executable.restart(Executable.java:94)
  23. at Executable.start(Executable.java:69)
  24. at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
  25. at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
  26. at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
  27. at java.base/java.security.AccessController.doPrivileged(Native Method)
  28. at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
  29. at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
  30. at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  31. at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
  32. ... 1 more
  33. Exception running application Executable
  34. Process finished with exit code 1


 
Comme vu dans le log voici la classe Executable et Acceuil
 
Executable:
 

Code :
  1. public class Executable extends Application {
  2.     private Pane root;
  3.     private Group caracteres;
  4.     private GestionJeu gestionnaire;
  5.     private int hauteurTexte;
  6.     private int largeurCaractere;
  7.     private Executable e = this;
  8.     private boolean accesMenu = true;
  9.     private Scene scene;
  10.     public static void main(String[] args) {
  11.         launch(args);
  12.     }
  13.     private void afficherCaracteres(){
  14.         caracteres.getChildren().clear();
  15.         int hauteur = (int) root.getHeight();
  16.         for( ChainePositionnee c : gestionnaire.getChaines().chaines)
  17.         {
  18.             Text t = new Text (c.x*largeurCaractere,hauteur - c.y*hauteurTexte, c.c);
  19.             t.setFont(Font.font ("Monospaced", 10));
  20.             caracteres.getChildren().add(t);
  21.         }
  22.     }
  23.     private void lancerAnimation() {
  24.         Timeline timeline = new Timeline(
  25.                 new KeyFrame(Duration.seconds(0),
  26.                     new EventHandler<ActionEvent>() {
  27.                         @Override public void handle(ActionEvent actionEvent) {
  28.                             gestionnaire.jouerUnTour();
  29.                             afficherCaracteres();
  30.                         }
  31.                     }),
  32.                 new KeyFrame(Duration.seconds(0.025))
  33.                 );
  34.         timeline.setCycleCount(Animation.INDEFINITE);
  35.         timeline.play();
  36.     }
  37.     @Override
  38.         public void start(Stage primaryStage) {
  39.             primaryStage.setTitle("Space Invader" );
  40.             Text t=new Text("█" );
  41.             t.setFont(Font.font("Monospaced",10));
  42.             hauteurTexte =(int) t.getLayoutBounds().getHeight();
  43.             largeurCaractere = (int) t.getLayoutBounds().getWidth();
  44.             restart();
  45.             primaryStage.setScene(scene);
  46.             primaryStage.setResizable(false);
  47.             primaryStage.show();
  48.             lancerAnimation();
  49.         }
  50.     public Pane getRoot() {
  51.         return root;
  52.     }
  53.     public Group getCaracteres() {
  54.         return caracteres;
  55.     }
  56.     public void setAccesMenu(boolean accesMenu) {
  57.         this.accesMenu = accesMenu;
  58.     }
  59.     public GestionJeu getGestionnaire() {
  60.         return gestionnaire;
  61.     }
  62.     public void restart(){
  63.         if (accesMenu){
  64.             root = new Accueil(this.e);
  65.         }else{
  66.             root= new AnchorPane(caracteres);
  67.         }
  68.         caracteres = new Group();
  69.         gestionnaire = new GestionJeu(e);
  70.         this.scene = new Scene(root,gestionnaire.getLargeur()*largeurCaractere,gestionnaire.getHauteur()*hauteurTexte);
  71.         System.out.println(gestionnaire.getLargeur()*largeurCaractere +" "+gestionnaire.getHauteur()*hauteurTexte);
  72.         if (!accesMenu){
  73.             scene.addEventHandler(KeyEvent.KEY_PRESSED, (key) -> {
  74.                 if(key.getCode()== KeyCode.LEFT)
  75.                     gestionnaire.toucheGauche();
  76.                 if(key.getCode()==KeyCode.RIGHT)
  77.                     gestionnaire.toucheDroite();
  78.                 if(key.getCode()==KeyCode.SPACE)
  79.                     gestionnaire.toucheEspace();
  80.             });
  81.         }
  82.         this.accesMenu = false;
  83.     }
  84. }


 
Acceuil:

Code :
  1. public class Accueil extends Pane {
  2.     private Executable e;
  3.     public Accueil(Executable e){
  4.         super();
  5.         getChildren().addAll(banniere(), menu());
  6.         this.e = e;
  7.     }
  8.     private HBox banniere(){
  9.         HBox box = new HBox();
  10.         box.setAlignment(Pos.CENTER);
  11.         box.setSpacing(10);
  12.         Image banniere = new Image("Images/banniere.png" );
  13.         ImageView iBanniere = new ImageView();
  14.         iBanniere.setImage(banniere);
  15.         iBanniere.smoothProperty();
  16.         box.getChildren().addAll(iBanniere);
  17.         return  box;
  18.     }
  19.     private FlowPane menu(){
  20.         FlowPane box = new FlowPane();
  21.         HBox box2 = new HBox();
  22.         VBox box3 = new VBox();
  23.         box.setOrientation(Orientation.VERTICAL);
  24.         box.setAlignment(Pos.CENTER);
  25.         box.setVgap(20);
  26.         box2.setSpacing(20);
  27.         Label tWave = new Label("Nombre de vagues" );
  28.         TextField wave = new TextField();
  29.         Button play = new Button("Jouer" );
  30.         CheckBox activeBoss = new CheckBox("Boss" );
  31.         ActionAccueil ac = new ActionAccueil(this.e);
  32.         wave.setOnAction(ac);
  33.         play.setOnAction(ac);
  34.         activeBoss.setOnAction(ac);
  35.         box3.getChildren().addAll(tWave, wave);
  36.         box2.getChildren().addAll(play, box2);
  37.         box.getChildren().addAll(box2, activeBoss);
  38.         return box;
  39.     }
  40. }


mood
Publicité
Posté le 20-02-2019 à 18:59:14  profilanswer
 

n°2329486
DDT
Few understand
Posté le 20-02-2019 à 23:03:54  profilanswer
 

Tu utilises Java 9/10/11? Ça ressemble à un problème de module.
 
https://www.google.com/search?q=bec [...] erflow.com
Y a plusieurs moyens, le mieux est d'utiliser un fichier module-info.java, apparemment IntelliJ peut le générer automatiquement.
 
Sinon downgrade vers Java 8.


---------------
click clack clunka thunk

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  java.lang.reflect.InvocationTargetException dans un projet

 

Sujets relatifs
Java Spring Boot - oauthRecherche professeur pour apprendre à programmer en Java
Recherche de testeurs pour debug Java JDK[JAVA] exécution projet multi-package
[Java] Aide débutant JavaJava calcule moyen des heure
(Projet) Rappel de valeur d'un fichier variableQui veut m'aider à créer un ensemble d'applications similaire à java?
Projet de stage php/mysql 
Plus de sujets relatifs à : java.lang.reflect.InvocationTargetException dans un projet


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR