Alternative API
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

Aller en bas
wolffen
wolffen
Messages : 7
Date d'inscription : 22/09/2020

API [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mar 22 Sep - 18:14
Tutoriel suivi: [Pt.1] Créer un launcher Minecraft Animé | Interface graphique
Code d'erreur:

Code:
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NullPointerException: Cannot invoke "java.net.URL.toURI()" because "resourceUrl" is null
    at fr.trxyy.alternative.alternative_api.utils.ResourceLocation.getMedia(ResourceLocation.java:21)
    at fr.lolitrust.launcher.LauncherMain.createContent(LauncherMain.java:39)
    at fr.lolitrust.launcher.LauncherMain.start(LauncherMain.java:32)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    ... 1 more
Exception running application fr.lolitrust.launcher.LauncherMain

Décrivez votre problème:

Je suis a 23.25 du tuto, au moment de lancer pour un premier teste, j'ai l'erreur affiché plus haut. Le code est exactement le même que sur le Tuto, j'ai correctement importé les lib Jfx (testé dans dans un projet a part).
Je comprend pas cette erreur :
Code:
Cannot invoke "java.net.URL.toURI()" because "resourceUrl" is null

Enfin je comprend ce quelle dit mais je n'arrive pas a comprendre ce qui la provoque.

Merci d'avance.
Trxyy
Trxyy
Administrateur
Messages : 52
Date d'inscription : 28/04/2020
Localisation : Par là
https://alternativeapi.forumactif.com/

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mar 22 Sep - 18:20
Salut, 


D'après ton erreur, elle provient de ta classe LauncherMain ligne 39.
sinon peux-tu m'envoyer ta classe LauncherMain sur https://hasteb.in/ ?

wolffen aime ce message

wolffen
wolffen
Messages : 7
Date d'inscription : 22/09/2020

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mar 22 Sep - 19:12
Merci pour ta réponse rapide.

Voila le package complet : https://hasteb.in/wiwayaqo.java

et le screen pour les nom des dépendances.

[En cours] Erreur : Cannot invoke "java.net.URL.toURI()" Sans_t10

Merci pour votre aide.
Trxyy
Trxyy
Administrateur
Messages : 52
Date d'inscription : 28/04/2020
Localisation : Par là
https://alternativeapi.forumactif.com/

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mar 22 Sep - 19:17
En essayant de mon coté ta classe, elle fonctionne parfaitement.
Essaye de mettre à jour la librairie et de voir si cela peut résoudre ton problème.
https://github.com/TrxyyDev/AlternativeAPI/releases/tag/1.2.64
wolffen
wolffen
Messages : 7
Date d'inscription : 22/09/2020

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mar 22 Sep - 19:58
Bien, j'ai téléchargé et ajouté la "AlternativeAPI-1.2.64.jar" dans le rep. lib, j'ai ajouté le "path", et enlever l'ancien "path", j'arrive pas à effacer l'ancienne...

Je comprend que "resourceUrl" est null mais il est nul part dans le code, j'ai enlevé aussi la ligne 3

Code:
import java.net.URL;

car ça change rien, je l'avais mis pour essayer de résoudre ce problème.

J'obtiens la même erreur...

J'ai ajouté un projet jfx telle quel j'ai ajouté les options VM et je l'ai lancé, cela fonctionne avec ce projet vierge...

Merci d'avance...
wolffen
wolffen
Messages : 7
Date d'inscription : 22/09/2020

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mer 23 Sep - 13:01
Bon j'ai continué mes recherche et en faisant ceci :

Code:
    @Override
    public void start(Stage primaryStage) throws Exception {

        Scene scene = new Scene(createContent());
        LauncherBase launcherBase = new LauncherBase(primaryStage, scene, StageStyle.DECORATED, gameEngine);
        //launcherBase.setIconImage(primaryStage,getResourceLocation().loadImage(gameEngine, "favicon.png"));
    }
    
    private Parent createContent() {

        LauncherPane contentPane = new LauncherPane(gameEngine);
        //new LauncherBackground(gameEngine, getResourceLocation().getMedia(gameEngine, "background.mp4"), contentPane);
        new LauncherPanel(contentPane, gameEngine);
        BorderPane contentPane = new BorderPane();

        return contentPane;
    }
J’obtiens l'affichage de la fenêtre (pane)... et plus l'erreur.

essaye suivant :

Code:
@Override
 public void start(Stage primaryStage) throws Exception {

 Scene scene = new Scene(createContent());
 LauncherBase launcherBase = new LauncherBase(primaryStage, scene, StageStyle.UNDECORATED, gameEngine);
 //launcherBase.setIconImage(primaryStage,getResourceLocation().loadImage(gameEngine, "favicon.png"));
 }
 
 private Parent createContent() {

 LauncherPane contentPane = new LauncherPane(gameEngine);
 //new LauncherBackground(gameEngine, getResourceLocation().getMedia(gameEngine, "background.mp4"), contentPane);
 //new LauncherPanel(contentPane, gameEngine);
 return contentPane;
 }

Affichage de la fenêtre et pas d'erreur. On dirait que c'est en rapport direct avec les ressources...

à suivre...
wolffen
wolffen
Messages : 7
Date d'inscription : 22/09/2020

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mer 23 Sep - 15:48
Bon après divers teste et des recherches sur internet (infructueuse), il apparait que cela fonctionne si je retire les 2 lignes qui appelles des ressources.
Code:
new LauncherBackground(gameEngine, getResourceLocation().getMedia(gameEngine, "background.mp4"), contentPane);
launcherBase.setIconImage(primaryStage, getResourceLocation().loadImage(gameEngine, "favicon.png"));

Donc je pense que ou, cela viens du répertoire qui contient les ressources (ce qui me parait improbable) ou il y a une incompatibilité avec ma version de java et javaFX (j'ai les dernières versions).

Des idées ?
wolffen
wolffen
Messages : 7
Date d'inscription : 22/09/2020

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Mer 23 Sep - 22:12
Le problème est résolu suite au conseil d'un membre sur le Discord, j'ai maintenant cette erreur :

Caused by: java.lang.IllegalAccessError: class com.sun.media.jfxmediaimpl.NativeMediaManager (in unnamed module @0xb6d48b5) cannot access class com.sun.glass.utils.NativeLibLoader (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.utils to unnamed module @0xb6d48b5

sur l'objet scene.

Merci.
Trxyy
Trxyy
Administrateur
Messages : 52
Date d'inscription : 28/04/2020
Localisation : Par là
https://alternativeapi.forumactif.com/

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Sam 26 Sep - 22:14
Peux-tu m'envoyer un message privé sur discord que nous voyons cela ensemble ? Trxyy#2332
Contenu sponsorisé

API Re: [En cours] Erreur : Cannot invoke "java.net.URL.toURI()"

Revenir en haut
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum