#Code not running (javafx)

1 messages · Page 1 of 1 (latest)

proven kiln
#

First of all, this is a simple side scroller beatemup game. It's just supposed to be a simple project that uses javafx. it wont boot up properly. I don't know how to explain the issue because this has to do with the setting up of the environment rather than the actual code not working I believe.

im getting errors such as

exception in Application start method.
and a larger wall of text following with many different errors that, once again, seem to be not errors with the code itself

(for the record, my project partner was the one who created it. I'm just attempting to get it set up for myself. They are also having issues with it.)

I dont know how to explain the problem further.

modern adderBOT
#

<@&987246487241105418> please have a look, thanks.

quiet robin
#

It would be helpful sharing the full error

#

also are you using maven or gradle?

#

it may be helpful sharing the build settings as well

proven kiln
#

Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1149)
Caused by: java.lang.RuntimeException: Exception in Application start method
at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
at [email protected]/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.Error: Unresolved compilation problem:
MainGameApp cannot be resolved

    at beatemup.GameManager.<init>(GameManager.java:148)
    at beatemup.Main.start(Main.java:11)
    at [email protected]/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
    at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
    at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
    at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at [email protected]/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at [email protected]/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185)
    ... 1 more

Exception running application beatemup.Main

#

oops

#

uh, that's the error im getting

quiet robin
#
Caused by: java.lang.Error: Unresolved compilation problem:
        MainGameApp cannot be resolved

        at beatemup.GameManager.<init>(GameManager.java:148)
        at beatemup.Main.start(Main.java:11)

this kinda shows that the error seems to be in your code

#

please share Main and GameManager

#

or at least the relevant sections

proven kiln
#

ok one sec. btw, what's that thing that formats code here in discord

#

like what are the symbols

modern adderBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

quiet robin
#

this explains it

proven kiln
#

ah thanks

#

MAIN:

package beatemup;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        GameManager gameManager = new GameManager();
        Pane root = gameManager.getGamePane();
        Scene scene = new Scene(root, 800, 600);
        primaryStage.setTitle("Beat 'Em Up Survival");
        primaryStage.setScene(scene);
        primaryStage.show();
        gameManager.startGameLoop();
    }

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

modern adderBOT
# proven kiln MAIN: ``` package beatemup; import javafx.application.Application; import javaf...

Detected code, here are some useful tools:

[WARNING] The code couldn't end properly...

Problematic source code:

package beatemup;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        GameManager gameManager = new GameManager();
        Pane root = gameManager.getGamePane();
        Scene scene = new Scene(root, 800, 600);
        primaryStage.setTitle("Beat 'Em Up Survival");
        primaryStage.setScene(scene);
        primaryStage.show();
        gameManager.startGameLoop();
    }

    public static void main(String[] args) {
        launch(args);
    }
}```
Cause:
The code doesn't compile:
illegal start of expression

## System out
[Nothing]
modern adderBOT
proven kiln
#

the gamemanager's code is much too large

#

ill send the txt file though

modern adderBOT
# proven kiln

I uploaded your attachments as Gist. This makes them more accessible, for example to mobile users.

proven kiln
quiet robin
#

all good

#

so let me give you a walkthrough

proven kiln
#

yes please

quiet robin
#

You have this error, what information does it give you?

Caused by: java.lang.Error: Unresolved compilation problem:
        MainGameApp cannot be resolved
        at beatemup.GameManager.<init>(GameManager.java:148)
        at beatemup.Main.start(Main.java:11)
proven kiln
#

is it simply because I'm calling main incorrectly?

#

it isn't supposed to be MainGameApp but rather Main?

quiet robin
#

not necessarily, lets just stick to the reason first before trying to fix it

#

what is the reason for the error

#

and where is it located in your code

proven kiln
#

well, it's saying at 148, there is an error. it

#

148 in gamemanager

quiet robin
#

exactly

proven kiln
#

MainGameApp.setScene("start");

quiet robin
#

yep

#

do you know what this means then:

Caused by: java.lang.Error: Unresolved compilation problem:
        MainGameApp cannot be resolved
proven kiln
#

simply because it doesn't exist right?

#

not a class?

#

or file

#

or something

quiet robin
#

maybe
the reason is it doesnt know about the MainGameApp class that you are trying to use in that line

#

that can have many reasons

#

maybe missing import

#

maybe that file doesnt even exist etc

#

do you have a class MainGameApp?

proven kiln
#

these are all my files and I don't believe it exists anywhere

quiet robin
#

then why are you trying to use it?

proven kiln
#

it was my project partner who did most of the code. I just believed in them since they took lead of the project

quiet robin
#

hm fair

#

then it makes sense to ask them

proven kiln
#

i shall do that right now but the current fix sounds like changing the MainGameApp into Main probably right? I can only assume that was the intent anyways

quiet robin
#

well as you said, its just an assumption (which is probably wrong)

#

it tries to use a static method setScene and Main doesnt have that

#

so it wont work either

proven kiln
#

i see

#

I am pretty sure this guy fell asleep after giving me his debugging work. how annoying

quiet robin
#

lol

proven kiln
#

i believe the method setScene doesn't exist

quiet robin
#

try a search all

#

but it might even be intented if this is group work

proven kiln
#

i see

quiet robin
#

maybe he wants you (or someone else) to create that class and implement that functionality

proven kiln
#

wait, maybe he just made a simple mistake of, in game manager, using setScene instead of getScene?

#

actually

#

that's probably wrong

quiet robin
#

I doubt that, but best thing would be asking the person about the intent

proven kiln
#

He wasn't asleep in the end but he just says, "I must've imss spelled it or I didn't check very well what I was typing in for the code."

I think bro chat gpt'd this. I dont think this guy knows what's going on whatsoever.

quiet robin
#

yeah, so did he even tried the code?

proven kiln
#

I feel like accidentally using an incorrect class like that or just a wrong name is very chatgpt to do

proven kiln
#

idk

quiet robin
#

seems like you arent using a build tool, which would be the first mistake in a group project

proven kiln
#

It sucks cause I was working on code before that ACTUALLY ran (despite it not looking very nice)
but he offered to do the code while I did the presentation

proven kiln
quiet robin
#

nah

#

it helps setting up your project and working in basically every environment

#

like you are using vsc and imagine someone else using intellij

#

but build tools do a lot more

#

and are complex, you probably didnt learn them yet

proven kiln
#

i think i may understand

quiet robin
#

which makes it harder to do group projects though

proven kiln
#

yeah they didn't teach us to do javafx or anything else

#

just the basics and they want a project on it

#

dunno

quiet robin
#

these might be helpful

modern adderBOT
#
proven kiln
#

do you think it's feasible to set up another file and transferring everything?

#

also, what are the version differences between 24 and 21

#

like, do the functions change name

#

i am thinking of changing from 24 to 21 simply because I had it working on my previous project

quiet robin
#

your version shouldnt matter too much

#

why do you want java 21?

maiden cloak
#

Java is a backwards compatible language, and JavaFX wise there are no major changes you should be impacted by.

proven kiln
# quiet robin why do you want java 21?

im thinking irrationally. a bit stressed from the situation. I really do think my project partner has gone to sleep this time (it is 3am almost) and im basically alone in this at this point

I am ok now but i was just grasping at straws trying to get see if there was a simple fix that just somehow fixes everything

quiet robin
proven kiln