#Why Others fmxl files not exist with the main and it work working before change it to "Jar"?

114 messages · Page 1 of 1 (latest)

tardy lichen
#

Hello I Build My Project to Jar and I put all DLL to lib of java so it works with javafx but when i try like go other fmxl page it don't even work and all my sounds i put get removed or something How fix this?

sleek hawkBOT
#

⌛ This post has been reserved for your question.

Hey @tardy lichen! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

#

<@&765578700724371486>

Requested by Boy Sky#4804
tardy lichen
#

Please help I go youtube and all like sources but get no answer!

#

if you know ping me!

#

sorry @fluid bough

#

But can i have help?

fluid bough
#

What doesn't work?

#

How do you know it doesn't work?

#

Are there any exceptions/stack traces/errors?

tardy lichen
#

Frist Of all everything was working and fine when i run it in intellj

#

but when i covert it from code to jar the only main file is working but others files that i link with don't do anything even the sounds

#

i use javafx sensebuilder to build my gui

fluid bough
#

What is shown in the console?

#

Can you show the specific code that doesn't work?

tardy lichen
#

i have like 4 fxml files

#

the only one that show me is "Main.fxml" but all other is even show

#

how it gonna load the other fxml you might ask?

fluid bough
#

Yes

tardy lichen
#
    @FXML
    void settingsButton(ActionEvent event) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
        Sound button = new Sound();
        button.button(this);
        root = FXMLLoader.load(getClass().getResource("Settings.fxml"));
        stage = (Stage)((Node)event.getSource()).getScene().getWindow();
        scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
fluid bough
#

and what is the console output?

tardy lichen
#

like here this a button that run "settings.fxml" file

#

but it not run it

tardy lichen
#

intellj working fine and everything

fluid bough
#

You can still get the console output when running a JAR

tardy lichen
#

but when i corvert it to .jar a build the artifact it not show anthing

fluid bough
#

I want to see the console output when running the application as a JAR

fluid bough
#

open your terminal in the directory of your JAR

#

and run java -jar yourjar.jar where yourjar.jar is your JAR file

tardy lichen
#

Ok 1 sec

#

sorry how open terminal from intellj?

#

oh

#

this one i see

#

this what it show me

#

idk why it not opening lol

fluid bough
#

first of all, move to the directory your JAR is located

#

using cd or similar

#

Secondly, put the name of your JAR instead of yourjar.jar, not after it

#

Thirdly, if there are spaces, you might need to quote them with ""

tardy lichen
#

Oh

#

ok

#

ok!

#

java -jar "Nation Quest (Beta 1).jar"

#

it working

#

and it frist thing now

#

when i click button

#

it send error

#

this error or smth was not happend in intellj

fluid bough
#

Can you show Sound.java, specifically line 22?

#

and the lines before

tardy lichen
#

Ok!

#

here all 😂 java public void button(Action action) throws UnsupportedAudioFileException, IOException, LineUnavailableException { File file; try { file = new File(Main.class.getResource("Sounds/Button-s.wav").toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e); } AudioInputStream audioStream = AudioSystem.getAudioInputStream(file); clip.stop(); clip.close(); clip.open(audioStream); clip.start();

fluid bough
#

it is not a file

tardy lichen
#

and line 22

#

ah

fluid bough
#

the resource is a URL, yes

#

but not a file

#

file means actual file outside the JAR

tardy lichen
#

oh

fluid bough
#

AudioSystem.getAudioInputStream(Main.class.getResource("Sounds/Button-s.wav"));

tardy lichen
#

it in reaouses

fluid bough
#

just do it like that

fluid bough
#

yes, without files

fluid bough
#

without files, no

tardy lichen
#

all my files in rouses it's in the project

fluid bough
tardy lichen
fluid bough
tardy lichen
# tardy lichen

all my files that i show here works in intellj but not in the jar

fluid bough
#

you probably have different problems as you had with the sound thing

tardy lichen
#

let me send you the error

fluid bough
#

recreate the JAR, run it with java -jar and check the console

tardy lichen
fluid bough
# tardy lichen

Are you sure you recreated the JAR after changing the code as I told you?

tardy lichen
#

java -jar Nation Quest (Beta 1).jar

#

again

fluid bough
#

with ""

tardy lichen
#

ok!

#

:0

#

it working

#

the sound here!

#

bruh now the other files working 💀

#

but what is this warning?

fluid bough
#

JavaFX is not intended to be run from a JAR like that

tardy lichen
#

ah

#

so how fix it?

fluid bough
#

not run it as a JAR

tardy lichen
#

Ye i want run it as a exe

fluid bough
#

yes, that works

tardy lichen
#

so i can fix that warning and put icon

fluid bough
#

at least if you have properly modularized your application

#

Then you can use jpackage/jlink to package it as an exe file

tardy lichen
#

Oh-

#

Wait

tardy lichen
#

up the page? of my window?

fluid bough
tardy lichen
#

Ok 10 Mins and I will close this Post if it works!

#

Ok Thank You!

#

Works!