Javafx Not importing

i have tried to follow yt but i thing i have done something wrong. the code is from GPT and i need it for my clg project. Is anyone willing to help?
No description
410 Replies
JavaBot
JavaBot4w ago
This post has been reserved for your question.
Hey @MeetnotFound | 12400f - 3070! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant 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.
dan1st
dan1st4w ago
Do you have a module-info.java file? Can you show the exact errors you are facing?
MeetnotFound | 12400f - 3070
how do i show u like send the ss here?
dan1st
dan1st4w ago
preferably show the errors as text but a screenshot is ok as well
MeetnotFound | 12400f - 3070
lol 32 errors
dan1st
dan1st4w ago
seems like you don't have JavaFX in your dependencies Are you using a build tool? e.g. Maven or Gradle
MeetnotFound | 12400f - 3070
i dont know whats that should i share u my screen? like i search in yt
dan1st
dan1st4w ago
JavaFX is not part of Java (SE). It's an external library.
MeetnotFound | 12400f - 3070
and he said that download from gluon some website the sdk file and extract it and in it have the code
dan1st
dan1st4w ago
If you want to use JavaFX, you need to tell it where to find that
MeetnotFound | 12400f - 3070
and in jason file he said that type vmargs smthg i did that but nthg happend
dan1st
dan1st4w ago
So you downloaded the JavaFX SDK? How did you add the JavaFX SDK to the Java application? Can you show that?
dan1st
dan1st4w ago
You need to add the JavaFX SDK to the referenced libraries as done here: https://stackoverflow.com/a/54535301/10871900
Stack Overflow
Visual Studio Code, Java Extension, how to add a JAR to classpath?
In Eclipse IDE, I add a JAR library using Project > Build Path > Configure Build Path... What is the equivalent in VisualStudioCode? I had a look into launch.json. There is a classpath defi...
dan1st
dan1st4w ago
So VSC should have a "Referenced Libraries" thing - Is that there for you?
MeetnotFound | 12400f - 3070
i did this
No description
MeetnotFound | 12400f - 3070
yes i added that
dan1st
dan1st4w ago
I don't think the --module-path lib/ is correct but that would only be applicable when running it Can you show the files in your project?
MeetnotFound | 12400f - 3070
its this only i men there are this files only yt said that have ut file in the downloaded SDK folder which i extracted
dan1st
dan1st4w ago
yes I saw that - but I meant the files in the actual project and not in the JavaFX SDK
MeetnotFound | 12400f - 3070
i dont what u want tbh m sorry but like this code is real time analyse (u knew ofc) so i have to provide it with mp3 file thats it and yea this is from GPT so i direct copy paste it i just only had an idea about the topic
dan1st
dan1st4w ago
In VSC, you have a Java project, right?
MeetnotFound | 12400f - 3070
yes i m using vscode
dan1st
dan1st4w ago
then please show the files within that project
MeetnotFound | 12400f - 3070
ok ok mb mb
dan1st
dan1st4w ago
not within the JavaFX SDK but in the project you opened
dan1st
dan1st4w ago
yes So you have the JavaFX SDK and the project/source files in the same directory?
dan1st
dan1st4w ago
that's not what people normally do but ok
MeetnotFound | 12400f - 3070
oh ok i just followed the yt if its allowed should i send u the yt link? like its basically promotion
dan1st
dan1st4w ago
Can you make the "Java projects" thing there bigger? it's fine though idk how useful it would be
dan1st
dan1st4w ago
Can you show the .vscode/settings file?
MeetnotFound | 12400f - 3070
anything u ask
dan1st
dan1st4w ago
Also you could try creating a folder named "src" and right-click on it - Does that show an "Add Folder to Java Source Path" option?
MeetnotFound | 12400f - 3070
is it in this i dont see it
MeetnotFound | 12400f - 3070
should i create it from vscode or do it in actually dir
dan1st
dan1st4w ago
in the directories at the top like you have bin, legal and lib - I would just add another folder named "src" Also what's the content of the bin folder?
MeetnotFound | 12400f - 3070
it didnt fit in one ss
No description
dan1st
dan1st4w ago
ok that could maybe conflict a bit Click the option "Add Folder to Java source path" and move your Java file to the src folder
dan1st
dan1st4w ago
Can you expand that?
MeetnotFound | 12400f - 3070
m so sorry m so dumb and asking u for so much typing and frustration
dan1st
dan1st4w ago
it's fine I think it might be easier to create a new project and use that
MeetnotFound | 12400f - 3070
now ill do it ur way ! can u guide me for that plzzzzzzz🥹 ?
dan1st
dan1st4w ago
Press Ctrl+P and select "Java: Create Java Project", then select "No build tool"
No description
dan1st
dan1st4w ago
then create a new folder for your project somewhere
dan1st
dan1st4w ago
type > Java project with the > and it should suggest the right thing I forgot to mention that you need the > for commands
MeetnotFound | 12400f - 3070
oh m sorry i even dont know the basics
dan1st
dan1st4w ago
It's a specific thing for VSC The third option is "Java: Create Java Project..." that should be what you need
MeetnotFound | 12400f - 3070
ok ok no build tools now its asking to select folder i mean the project location
MeetnotFound | 12400f - 3070
what folder shoul i select completly different one?
dan1st
dan1st4w ago
completely different one
MeetnotFound | 12400f - 3070
i did it in semester 4 folder is it ok? or maybe desktop
dan1st
dan1st4w ago
yes
dan1st
dan1st4w ago
but make sure to create a new folder for it
dan1st
dan1st4w ago
and there you need to enter a name
MeetnotFound | 12400f - 3070
music? is it ok
dan1st
dan1st4w ago
yes
MeetnotFound | 12400f - 3070
it opened a new window daniel ill come in just 5 mins plz
dan1st
dan1st4w ago
ok I think there should be a "Java Projects" somewhere maybe it's the "Projects" thing
MeetnotFound | 12400f - 3070
5 mins m back m back sorry for this
MeetnotFound | 12400f - 3070
the projects is empty
No description
dan1st
dan1st4w ago
What's shown when right-clicking src?
JavaBot
JavaBot4w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
MeetnotFound | 12400f - 3070
Hello Will u continue to help me daniel..? Or someone else will.?
dan1st
dan1st4w ago
Can you create the Java file there? in the source folder using the new Java file option or actually, is there a Java file in the src folder?
dan1st
dan1st4w ago
MeetnotFound | 12400f - 3070
there is app file already whats this?
No description
MeetnotFound | 12400f - 3070
yes like this?
No description
dan1st
dan1st4w ago
There is still no "Java projects" at the bottom?
MeetnotFound | 12400f - 3070
nah look
MeetnotFound | 12400f - 3070
oh there is java
dan1st
dan1st4w ago
No description
dan1st
dan1st4w ago
So you have a "Jaav projects" thing Can you expand that?
dan1st
dan1st4w ago
Can you press the + for the referenced libraries?
No description
MeetnotFound | 12400f - 3070
its empty
dan1st
dan1st4w ago
yeah if you hover over Referenced Libraries, there's a +
MeetnotFound | 12400f - 3070
yes there is
dan1st
dan1st4w ago
which should open the file explorer
MeetnotFound | 12400f - 3070
add lib there of javafx ?
dan1st
dan1st4w ago
Can you select the JARs from the JavaFX SDK there? so the JavaFX SDK you downloaded has a "lib" folder which has a few JARs in it
dan1st
dan1st4w ago
you can also do this
No description
dan1st
dan1st4w ago
and then view the libraries tab
No description
MeetnotFound | 12400f - 3070
i have this in lib of SDK file that i downloaded
dan1st
dan1st4w ago
select these JARs in VSC yes these are the JARs you need to add there
MeetnotFound | 12400f - 3070
yes i remeber yt said this too ill do it
dan1st
dan1st4w ago
ok now you are there again In your App.java, can you now access JavaFX classes?
MeetnotFound | 12400f - 3070
saying this
dan1st
dan1st4w ago
that means you are just not using that class
MeetnotFound | 12400f - 3070
should i send u the code i m tring to run? u want to take a look?
dan1st
dan1st4w ago
I think the source code isn't necessarily the problem Well maybe share the App class
dan1st
dan1st4w ago
Did you only add the import or did you add more?
MeetnotFound | 12400f - 3070
nah just import just this
dan1st
dan1st4w ago
try changing it to something like
import javafx.application.Application;
import javafx.stage.Stage;

public class App extends Application {
public static void main(String[] args) throws Exception {
launch(args);

}

@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.show();
}
}
import javafx.application.Application;
import javafx.stage.Stage;

public class App extends Application {
public static void main(String[] args) throws Exception {
launch(args);

}

@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.show();
}
}
MeetnotFound | 12400f - 3070
woah ok nah not working
MeetnotFound | 12400f - 3070
yt said that create this
MeetnotFound | 12400f - 3070
lauch file and add there vmargs smthg like that
dan1st
dan1st4w ago
only one App class And once you did that, can you click on the "Java: Ready" at the bottom?
dan1st
dan1st4w ago
yeah but that wouldn't help much until you got the other things working
MeetnotFound | 12400f - 3070
nah nah i didnt oh ok
dan1st
dan1st4w ago
Can you do it and show what happens?
dan1st
dan1st4w ago
Can you show the exact files that are present in the JavaFX SDK?
dan1st
dan1st4w ago
and also expand some of the things under "Referenced Libraries"?
dan1st
dan1st4w ago
Does it maybe look like that?
No description
dan1st
dan1st4w ago
or more like that?
No description
MeetnotFound | 12400f - 3070
like this
No description
MeetnotFound | 12400f - 3070
the file in sdk
No description
dan1st
dan1st4w ago
Which files are in lib exactly? ok that does look right
MeetnotFound | 12400f - 3070
the ones i added in reference
dan1st
dan1st4w ago
Can you press Ctrl+P and type something like Clean Java
No description
MeetnotFound | 12400f - 3070
with > right?
dan1st
dan1st4w ago
yes
dan1st
dan1st4w ago
and then reload and delete in the popup on the bottom right
No description
MeetnotFound | 12400f - 3070
java activating now searching done but its same
MeetnotFound | 12400f - 3070
after cleaning should i drop this idea and go to another one ? honestly m not blaming u or something but i think its my pc idk like YOU cant do it who else can its pc then
dan1st
dan1st4w ago
Can you click on the "Java: Ready" on the bottom and then select "Open logs"?
No description
dan1st
dan1st4w ago
Can you scroll down? Or just send the file here?
dan1st
dan1st4w ago
ok
dan1st
dan1st4w ago
Can you open that thing?
No description
dan1st
dan1st4w ago
configure classpath
dan1st
dan1st4w ago
and then check the libraries tab
No description
dan1st
dan1st4w ago
I mean, I am normally not using VSC that does look ok
MeetnotFound | 12400f - 3070
just dont take it like m blaming u or something plz.. tbh i m thinking ur reputation in this server tbh
dan1st
dan1st4w ago
and if you view the problems view, it shows you the imports cannot be resolved?
No description
dan1st
dan1st4w ago
it's ok - I know I cannot solve all issues though in principle, there are two other things you could try
MeetnotFound | 12400f - 3070
i cant find it what? uninstall and install again vsc?
dan1st
dan1st4w ago
- There is a different plugin for Java support in VSC - You could try using Maven
dan1st
dan1st4w ago
If you want to use Maven, you can that by doing the "create Java project" thing and selecting "JavaFX"
No description
MeetnotFound | 12400f - 3070
i did maven this came
No description
dan1st
dan1st4w ago
ah
MeetnotFound | 12400f - 3070
Executing task: ""c:\Users\Meet.vscode\extensions\vscjava.vscode-maven-0.44.0\resources\maven-wrapper\mvnw.cmd" org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="javafx-archetype-fxml" -DarchetypeGroupId="org.openjfx" -DarchetypeVersion="RELEASE" -DgroupId="music" -DartifactId="demo" -DoutputDirectory="c:\Users\Meet\Desktop"" Error: JAVA_HOME not found in your environment. Please set the JAVA_HOME variable in your environment to match the location of your Java installation. * The terminal process "cmd.exe /c ""c:\Users\Meet.vscode\extensions\vscjava.vscode-maven-0.44.0\resources\maven-wrapper\mvnw.cmd" org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="javafx-archetype-fxml" -DarchetypeGroupId="org.openjfx" -DarchetypeVersion="RELEASE" -DgroupId="music" -DartifactId="demo" -DoutputDirectory="c:\Users\Meet\Desktop""" terminated with exit code: 1. * Terminal will be reused by tasks, press any key to close it.
dan1st
dan1st4w ago
You can try enabling this in your VSC setting
No description
dan1st
dan1st4w ago
or possibly set that to your JDK installation directory if nothing is set there
No description
dan1st
dan1st4w ago
and trying again If that doesn't work, you can set it in your environment variables
MeetnotFound | 12400f - 3070
what do i do
dan1st
dan1st4w ago
Do you know where Java is installed?
MeetnotFound | 12400f - 3070
i dont know but its default
dan1st
dan1st4w ago
What's the output of where javac in your terminal?
dan1st
dan1st4w ago
yes but you'd need to select powershell on the right first or click on the +
dan1st
dan1st4w ago
type in where javac there
dan1st
dan1st4w ago
What happens if you just type javac? or java Did you ever install Java/a JDK? actually since you are using powershell, you might need to enter
(get-command java).Path
(get-command java).Path
or similar
dan1st
dan1st4w ago
or cmd /c where javac
MeetnotFound | 12400f - 3070
only java
dan1st
dan1st4w ago
typing java works but typing javac doesn't?
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Daniel\Music> (get-command java).Path C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin\java.exe this
dan1st
dan1st4w ago
great
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Daniel\Music> cmd /c where javac C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin\javac.exe C:\Program Files\Common Files\Oracle\Java\javapath\javac.exe
dan1st
dan1st4w ago
Then you should be able to create an environment variable named JAVA_HOME with the value C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot once you've done that, you should be able to restart VSC and create the JavaFX project normally or with the "Java: Create Project" > "JavaFX"
dan1st
dan1st4w ago
that thing
No description
MeetnotFound | 12400f - 3070
its currently downloding alot of files
dan1st
dan1st4w ago
that's fine then it seems to be working it should then also ask you a few things about your project
MeetnotFound | 12400f - 3070
Define value for property 'version' 1.0-SNAPSHOT: : ? asked me this in terminal
dan1st
dan1st4w ago
btw with that approach, you don't even need the JavaFX SDK
MeetnotFound | 12400f - 3070
on thats too great
dan1st
dan1st4w ago
you can either specify a version by just entering it or just press enter pressing enter means "leave it as what is suggested"
dan1st
dan1st4w ago
perfect now the pom.xml is the configuration of your project you can view it if you like for example if you want to change the JavaFX version, you can change it in your pom.xml and your code is in src/main/java
MeetnotFound | 12400f - 3070
oh great
dan1st
dan1st4w ago
I assume there is a class there? Can you run it?
Suika
Suika4w ago
module com.example {
requires javafx.controls;
requires javafx.fxml;

opens com.example to javafx.fxml;
exports com.example;
}
module com.example {
requires javafx.controls;
requires javafx.fxml;

opens com.example to javafx.fxml;
exports com.example;
}
This message has been formatted automatically. You can disable this using /preferences.
dan1st
dan1st4w ago
that is the module-info.java
MeetnotFound | 12400f - 3070
says app
dan1st
dan1st4w ago
that file (module-info.java) specifies what modules you are using and which packages should be available to other code
dan1st
dan1st4w ago
yes you should be able to run that class
dan1st
dan1st4w ago
No description
dan1st
dan1st4w ago
click the "Run" there
dan1st
dan1st4w ago
Can you show the output?
dan1st
dan1st4w ago
I meant copying the thing shown there like the whole text not just the thing that's on screen you might need to scroll up there in the debug console
MeetnotFound | 12400f - 3070
what u want me to copy ? whole debug console?
dan1st
dan1st4w ago
yes pretty much ideally
dan1st
dan1st4w ago
Can you show the pom.xml?
MeetnotFound | 12400f - 3070
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>13</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-fxml</artifactId> <version>13</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>11</release> </configuration> </plugin> <plugin> <groupId>org.openjfx</groupId> <artifactId>javafx-maven-plugin</artifactId> <version>0.0.6</version> <executions> <execution> <!-- Default configuration for running --> <!-- Usage: mvn clean javafx:run --> <id>default-cli</id> <configuration> <mainClass>com.example.App</mainClass> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
dan1st
dan1st4w ago
Can you replace the "13" with "23"? for the JavaFX dependencies Did you use the "Run" or the "Run main" thing there?
MeetnotFound | 12400f - 3070
for both 13?
dan1st
dan1st4w ago
yes
MeetnotFound | 12400f - 3070
yes run main
dan1st
dan1st4w ago
Can you try "Run"? idk why you have two there
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Dan1st\demo> & 'C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin\java.exe' '@C:\Users\Meet\AppData\Local\Temp\cp_b5w03lrc5yr09nmuc11y4vlai.argfile' '-m' 'com.example/com.example.App' Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.media not found PS D:\College\Semester 4\Dan1st\demo> ^output
dan1st
dan1st4w ago
can you right click the pom.xml and select reload projects
No description
dan1st
dan1st4w ago
that's just a warning and should be fine Did you modify your application to use javafx.media? Did you add all of your application there already?
MeetnotFound | 12400f - 3070
nthg at all .. all stock no
dan1st
dan1st4w ago
So your module-info.java is this?
module com.example {
requires javafx.controls;
requires javafx.fxml;

opens com.example to javafx.fxml;
exports com.example;
}
module com.example {
requires javafx.controls;
requires javafx.fxml;

opens com.example to javafx.fxml;
exports com.example;
}
dan1st
dan1st4w ago
Since it seems to look for javafx.media for some reason, I guess you can add a dependency in your pom.xml so copy one of the JavaFX dependencies and change the artifactId to javafx.media
MeetnotFound | 12400f - 3070
can u give it to me illjust paste there where were u want
dan1st
dan1st4w ago
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>23</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>23</version>
</dependency>
MeetnotFound | 12400f - 3070
should i add this at the end of pom file? or somewhere in between
dan1st
dan1st4w ago
to the other <dependency> blocks
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>23</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>23</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>23</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>23</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>23</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>23</version>
</dependency>
</dependencies>
dan1st
dan1st4w ago
looks good now try that and then try running it again
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Dan1st\demo> d:; cd 'd:\College\Semester 4\Dan1st\demo'; & 'C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin\java.exe' '@C:\Users\Meet\AppData\Local\Temp\cp_b5w03lrc5yr09nmuc11y4vlai.argfile' '-m' 'com.example/com.example.App' Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.media not found PS D:\College\Semester 4\Dan1st\demo> should i copy paste my code in src and run that ?
dan1st
dan1st4w ago
no I am not sure what is happening there
dan1st
dan1st4w ago
If you go to the run configurations, it shows "No confgurations", right?
No description
dan1st
dan1st4w ago
ok so it sais current file Can you open the App.java and then click the run button there?
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Dan1st\demo> d:; cd 'd:\College\Semester 4\Dan1st\demo'; & 'C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot\bin\java.exe' '@C:\Users\Meet\AppData\Local\Temp\cp_b5w03lrc5yr09nmuc11y4vlai.argfile' '-m' 'com.example/com.example.App' Error occurred during initialization of boot layer java.lang.module.FindException: Module javafx.media not found PS D:\College\Semester 4\Dan1st\demo>
dan1st
dan1st4w ago
and you did that thing, right?
MeetnotFound | 12400f - 3070
yes 2 times
dan1st
dan1st4w ago
That kind of seems like you added some JVM args
dan1st
dan1st4w ago
Did you add anything related to VM args in the settings?
No description
dan1st
dan1st4w ago
or that setting
No description
MeetnotFound | 12400f - 3070
ohh yea yea yea\ i remember yt yea i have
dan1st
dan1st4w ago
Did you add anything related to javafx.media?
MeetnotFound | 12400f - 3070
tbh i dont remembe can u tell me how to check it yup u r right
dan1st
dan1st4w ago
I think you can just remove everything from there
MeetnotFound | 12400f - 3070
ok now run? finally
MeetnotFound | 12400f - 3070
this opened m so sorry for that settings i completely forgot about that
dan1st
dan1st4w ago
no problem
MeetnotFound | 12400f - 3070
that could have been saved ur time
dan1st
dan1st4w ago
I saw that thing
@C:\Users\Meet\AppData\Local\Temp\cp_b5w03lrc5yr09nmuc11y4vlai.argfile'
which is where VSC injects that option xd
dan1st
dan1st4w ago
anyway you can now try to use your code instead
MeetnotFound | 12400f - 3070
u r too deep into these
dan1st
dan1st4w ago
And I should have told you to use Maven from the start on lol
MeetnotFound | 12400f - 3070
add the code in src?
dan1st
dan1st4w ago
you have the App.java already - you could use that
MeetnotFound | 12400f - 3070
nah man u the GOAT for me atleast
dan1st
dan1st4w ago
Are you using FXML in your code?
MeetnotFound | 12400f - 3070
thank u a LOT and SORRY for ur 2 days man i really apologize
JavaBot
JavaBot4w ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
MeetnotFound | 12400f - 3070
i dont know much can u check it plz
dan1st
dan1st4w ago
Is there any FXML file? in the code you want to use
MeetnotFound | 12400f - 3070
nah its just java file
dan1st
dan1st4w ago
ok
MeetnotFound | 12400f - 3070
and an mp3
dan1st
dan1st4w ago
so FXML is a format you can use for specifying your JavaFX UIs using a graphical program (Scene builder) it seems you aren't using them so you wouldn't need it
dan1st
dan1st4w ago
the generated project comes with two FXML files
No description
dan1st
dan1st4w ago
and also some configuration for FXML in principle, you could remove those at some point since your actual project doesn't need them
dan1st
dan1st4w ago
these files are just example files - except the module-info.java which is important
No description
dan1st
dan1st4w ago
you should be able to now use the files you want to use if the code you want to run uses javafx.media, you might need to add requires javafx.media to the module-info.java
MeetnotFound | 12400f - 3070
yes ig i m using media what do i do then
dan1st
dan1st4w ago
The module-info.java currently looks like that:
module com.example {
requires javafx.controls;
requires javafx.fxml;

opens com.example to javafx.fxml;
exports com.example;
}
module com.example {
requires javafx.controls;
requires javafx.fxml;

opens com.example to javafx.fxml;
exports com.example;
}
dan1st
dan1st4w ago
You'd need to add a requires saying you are using javafx.media:
module com.example {
requires javafx.controls;
requires javafx.fxml;
requires javafx.media;//I ADDED THIS HERE

opens com.example to javafx.fxml;
exports com.example;
}
module com.example {
requires javafx.controls;
requires javafx.fxml;
requires javafx.media;//I ADDED THIS HERE

opens com.example to javafx.fxml;
exports com.example;
}
If you want to remove FXML from the project at some point, you'd also remove the requires javafx.fxml; and opens com.example to javafx.fxml; from the module-info.java
dan1st
dan1st4w ago
ah
dan1st
dan1st4w ago
check the bottom
No description
dan1st
dan1st4w ago
Does it show something like that? it might need to download stuff first
dan1st
dan1st4w ago
And in the pom.xml, you have javafx-media, right?
dan1st
dan1st4w ago
You have a Maven view on the bottom left
No description
dan1st
dan1st4w ago
Can you expand Lifecycle and run the "compile" thing?
MeetnotFound | 12400f - 3070
it landed me here
dan1st
dan1st4w ago
oh ig you don't have Maven installed should be fine
dan1st
dan1st4w ago
Can you show a screenshot of your pom.xml? specifically the dependencies
dan1st
dan1st4w ago
Just for testing: If you change the javafx-media to javafx-media2 in your pom.xml, does it show some error there?
MeetnotFound | 12400f - 3070
no no error
dan1st
dan1st4w ago
Can you show a screenshot of that dependency again? you might need to install Maven for it to work
MeetnotFound | 12400f - 3070
its showing 2 errors
No description
dan1st
dan1st4w ago
ok these aren't errors (you can set it back)
dan1st
dan1st4w ago
you might need to install Maven if you haven't already
MeetnotFound | 12400f - 3070
from web?
dan1st
dan1st4w ago
and tell VSC where it can find Maven
MeetnotFound | 12400f - 3070
or extension
dan1st
dan1st4w ago
https://maven.apache.org/download.cgi Note that you need to install the binary version not the source version
dan1st
dan1st4w ago
so that thing
No description
MeetnotFound | 12400f - 3070
extracted the binary
dan1st
dan1st4w ago
Now you remember when you clicked on compile, it moved you to the settings?
No description
dan1st
dan1st4w ago
yes That's where you enter the path to your Maven executable In the Maven folder that you downloaded, there is a bin folder with an mvn.bat you'd enter the full path to the mvn.bat in that text field
MeetnotFound | 12400f - 3070
this file right?
dan1st
dan1st4w ago
mvn.cmd the mvn file is for Linux
MeetnotFound | 12400f - 3070
now i can run my file?
dan1st
dan1st4w ago
that file should be in src/main/java in some package also try the "compile" thing again now that you did that
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Dan1st\demo> & ""D:\College\Semester 4\apache-maven-3.9.9\bin\mvn.cmd"" compile -f "d:\College\Semester 4\Dan1st\demo\pom.xml" The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object. At line:1 char:3 + & ""D:\College\Semester 4\apache-maven-3.9.9\bin\mvn.cmd"" compile -f ... + ~~ + CategoryInfo : InvalidOperation: (:String) [], RuntimeException + FullyQualifiedErrorId : BadExpression PS D:\College\Semester 4\Dan1st\demo> after compile
dan1st
dan1st4w ago
you would need to copy the path without double quotes you shouldn't have the double quotes here
MeetnotFound | 12400f - 3070
what about source now?
dan1st
dan1st4w ago
source?
dan1st
dan1st4w ago
you don't need the source download only the binary zip which you downloaded and entered in VSC
dan1st
dan1st4w ago
the source is relevant if you are developing Maven or something like that
MeetnotFound | 12400f - 3070
now how do i run my file?
dan1st
dan1st4w ago
Can you try the "compile" thing again? after removing the double quotes I assume you have done that?
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Dan1st\demo> & "D:\College\Semester 4\apache-maven-3.9.9\bin\mvn.cmd" compile -f "d:\College\Semester 4\Dan1st\demo\pom.xml" [INFO] Scanning for projects... [ERROR] [ERROR] Some problems were encountered while processing the POMs: [ERROR] Malformed POM d:\College\Semester 4\Dan1st\demo\pom.xml: Unrecognised tag: 'dependencies' (position: START_TAG seen ...</dependency>\r\n <dependencies>... @18:27) @ d:\College\Semester 4\Dan1st\demo\pom.xml, line 18, column 27 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR]
[ERROR] The project com.example:demo:1.0-SNAPSHOT (d:\College\Semester 4\Dan1st\demo\pom.xml) has 1 error [ERROR] Malformed POM d:\College\Semester 4\Dan1st\demo\pom.xml: Unrecognised tag: 'dependencies' (position: START_TAG seen ...</dependency>\r\n <dependencies>... @18:27) @ d:\College\Semester 4\Dan1st\demo\pom.xml, line 18, column 27 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException PS D:\College\Semester 4\Dan1st\demo>
dan1st
dan1st4w ago
Can you show your pom.xml again? The error means something is wrong there
dan1st
dan1st4w ago
ah yeah this isn't valid so you should have one <dependencies> that contains all of the <dependency> elements and that <dependencies> block ends with a </dependencies> after all of the <dependency>...</dependency> elements you just copied my example code into your code but that example code was supposed to be the whole <dependencies> block
MeetnotFound | 12400f - 3070
so now what? oh coz i dont know to code this sorry for that
dan1st
dan1st4w ago
Can you copy the whole pom.xml as text?
MeetnotFound | 12400f - 3070
i just pasted it
dan1st
dan1st4w ago
actually I can just give you the whole pom.xml as it should be
dan1st
dan1st4w ago
ah ok
MeetnotFound | 12400f - 3070
thank u so much
JavaBot
JavaBot4w ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
dan1st
dan1st4w ago
dan1st
dan1st4w ago
that should be the correct one Each <dependency> block is one dependency/one library you are using and the <dependencies> block lists all of your dependencies So you want to use javafx-controls, javafx-fxml and javafx-media in there
MeetnotFound | 12400f - 3070
PS D:\College\Semester 4\Dan1st\demo> & "D:\College\Semester 4\apache-maven-3.9.9\bin\mvn.cmd" compile -f "d:\College\Semester 4\Dan1st\demo\pom.xml" [INFO] Scanning for projects... [INFO] [INFO] --------------------------< com.example:demo >-------------------------- [INFO] Building demo 1.0-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- resources:3.3.1:resources (default-resources) @ demo --- [INFO] Copying 2 resources from src\main\resources to target\classes [INFO] [INFO] --- compiler:3.8.0:compile (default-compile) @ demo --- [INFO] Nothing to compile - all classes are up to date [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.612 s [INFO] Finished at: 2025-02-08T00:33:48+05:30 [INFO] ------------------------------------------------------------------------ PS D:\College\Semester 4\Dan1st\demo> done yea
dan1st
dan1st4w ago
now do the update project thing
MeetnotFound | 12400f - 3070
using these
No description
dan1st
dan1st4w ago
reload projects*
No description
dan1st
dan1st4w ago
and then check your module-info.java
MeetnotFound | 12400f - 3070
all good
dan1st
dan1st4w ago
nice With a good pom.xml without copying mistakes, it works ;)
MeetnotFound | 12400f - 3070
yea fianlly
dan1st
dan1st4w ago
Now there is still an error there you are using a module-info.java. This means all classes need to be in a package
MeetnotFound | 12400f - 3070
yea at first
dan1st
dan1st4w ago
so the file shouldn't just be in src/main/java bit in src/main/java/com/example
MeetnotFound | 12400f - 3070
how do i do that
dan1st
dan1st4w ago
or whereever your other java file is
dan1st
dan1st4w ago
and then you need a line specifying that package in the beginning of your file - for example package com.example; that must match the directory you put it in don't just blindly copy it but think about what you are doing
MeetnotFound | 12400f - 3070
i placed them in example so it should be fine um the mp3 file is running only for 2 secs maybe 1 sec and then stopping u wanna try this code plz with the mp3 i have?
dan1st
dan1st4w ago
Does the whole application stop? or is the UI still active?
MeetnotFound | 12400f - 3070
ui is active
dan1st
dan1st4w ago
I guess it would probably help Is there any output?
MeetnotFound | 12400f - 3070
yes wroking smooth
MeetnotFound | 12400f - 3070
music is loud (disclaimer)
dan1st
dan1st4w ago
I assume the visualization stops as well?
MeetnotFound | 12400f - 3070
yes ok this runs smoothly
dan1st
dan1st4w ago
Stack Overflow
JavaFX MediaPlayer - Music stops after 10 seconds
Here's the code, like the title says the music stops after 10ish seconds, i played the file normally in vlc or other programs, it lasts more than 5 minutes. public void music(){ String bip...
dan1st
dan1st4w ago
yes that is the fix
MeetnotFound | 12400f - 3070
brother i have no words for ur help i really appreciate that thank you alot
JavaBot
JavaBot4w ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
MeetnotFound | 12400f - 3070
should i close this now ? post
dan1st
dan1st4w ago
no problem If you think you'll still need this post, you can keep it open - otherwise closing is the better option (or it would be marked as dormant at some point)
MeetnotFound | 12400f - 3070
ill keep it open until the submission if u dont mind
dan1st
dan1st4w ago
btw you can remove the classes that are unrelated to your visualizer
JavaBot
JavaBot4w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?