Setting up environment for GUI development with JavaFX in VS Code Editor. [Modified and Efficient]

  Рет қаралды 10,802

Innovator

Innovator

Күн бұрын

Пікірлер: 46
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Some problems to which these are solutions. 1. "Error: Could not find or load main class app Caused by: java.lang.ClassNotFoundException: app" Solution: When u click the run button , VS code gives a warning, "The file app.java isn't on the classpath, the runtime may throw class not found error. Do you want to add the parent folder "APP/JavaFx Application/src" to Java source path?" Click yes. This warning is show only if you have installed "Debugger for Java" extension. If this warning is not shown by your VS code, then you can paste the below code in your settings.json, where you find the location of your jar files that you import. ``` "java.project.sourcePaths": [ "JavaFx Application/src" ] ``` If you have any other projects to add under this project, you can update this list accordingly. 2. After this you might me seeing one more error. "Error: JavaFX runtime components are missing, and are required to run this application" Solution: Fist, Debug your application's code. Can be done by "create a launch.json file" under "RUNAND DEBUG" of Explorer section. Add this vmArgs to the configuration which has the projectName in it. ``` "vmArgs": "--module-path D:\\Java_JFX\\javafx-sdk-14.0.2.1\\lib --add-modules javafx.controls,javafx.fxml", ``` It should be the path to the JavaFX lib folder. Then it will work. 👌✨ like anything !!
@user-pd4wz1oo3x
@user-pd4wz1oo3x 2 жыл бұрын
thank you!!!! it worked :D
@picnicbros
@picnicbros 2 жыл бұрын
Works like a charm, thank you!
@harshith_takkala
@harshith_takkala 4 жыл бұрын
Like the video if you find it useful. Cheers !!😀✌👍
@shoyur
@shoyur 2 жыл бұрын
If i move the project to another folder, it creates another object in the launch.js, this new object doesnt have the vmargs so i get the error again, do you know why please ? thx
@harshith_takkala
@harshith_takkala 2 жыл бұрын
Yeah This is the problem I too faced. I dont know why. I just copy pasted the same key value pair in the newly created object.
@gouthamreddy4275
@gouthamreddy4275 4 жыл бұрын
This video changed my whole life THANK U
@harshith_takkala
@harshith_takkala 4 жыл бұрын
😅😅
@badabeta6973
@badabeta6973 3 жыл бұрын
I'm having a problem running the program -> Error: Could not find or load main class javafx.controls, javafx.fxml Caused by: java.lang.ClassNotFoundException: javafx.controls, javafx.fxml Iam facing this problem can you help with it !!!!!!!
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Hey, You must run the program with "Java code runner" but not with "code runner"(basically used for all programs but not for projects). ✌
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Hey, sorry for late reply but now I understood your problem. 1. "Error: Could not find or load main class app Caused by: java.lang.ClassNotFoundException: app" Solution: When u click the run button , VS code gives a warning, "The file app.java isn't on the classpath, the runtime may throw class not found error. Do you want to add the parent folder "APP/JavaFx Application/src" to Java source path?" Click yes. This warning is show only if you have installed "Debugger for Java" extension. If this warning is not shown by your VS code, then you can paste the below code in your settings.json, where you find the location of your jar files that you import. ``` "java.project.sourcePaths": [ "JavaFx Application/src" ] ``` If you have any other projects to add under this project, you can update this list accordingly. 2. After this you might me seeing one more error. "Error: JavaFX runtime components are missing, and are required to run this application" Solution: Fist, Debug your application's code. Can be done by "create a launch.json file" under "RUNAND DEBUG" of Explorer section. Add this vmArgs to the configuration which has the projectName in it. ``` "vmArgs": "--module-path D:\\Java_JFX\\javafx-sdk-14.0.2.1\\lib --add-modules javafx.controls,javafx.fxml", ``` It should be the path to the JavaFX lib folder. Then it will work. 👌✨ like anything !!
@ctx4241
@ctx4241 2 жыл бұрын
Aaaaand obligatory question... do you know how to make runnable jar out of it?
@harshith_takkala
@harshith_takkala 2 жыл бұрын
Yes. Make a java project (follow the video for servlet development, and then instead of those dependencies, search for javafx dependencies in central maven repository) Then after all programming part, you can use "mvn war" command to create a war package. Hope you got it
@ctx4241
@ctx4241 2 жыл бұрын
@@harshith_takkala no, you are making video about VSC, no build tools, javaFX. Can you export runnable jar from JavaFX project in VSC, no build tools?
@harshith_takkala
@harshith_takkala 2 жыл бұрын
@@ctx4241 only with the help of vscode, we cannot do it. Only with maven as build tool, we can do it
@matheusvinicius1420
@matheusvinicius1420 4 жыл бұрын
I'm having a problem running the program -> Error: Could not find or load main class javafx.controls, javafx.fxml Caused by: java.lang.ClassNotFoundException: javafx.controls, javafx.fxml Would you help me out of this?
@harshith_takkala
@harshith_takkala 4 жыл бұрын
Hey! I am not getting any error of this kind. May be: 1. Restart the whole procedure again, (backup the code required). 2. Check out my previous video on the same topic for initial installations and others. 3. Make sure all jar files are imported under referenced libraries section 4. Type the correct value for vmArgs in json file 5. I took reference from this: stackoverflow.com/questions/54349894/javafx-11-with-vscode Hope you got it !! This is my launch.json file { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "java", "name": "Debug (Launch) - Current File", "request": "launch", "mainClass": "${file}" }, { "type": "java", "name": "Debug (Launch)-App", "request": "launch", "mainClass": "App", "vmArgs": "--module-path --add-modules javafx.controls,javafx.fxml", "projectName": "application_6f235254" } ] }
@0x5c
@0x5c 4 жыл бұрын
I know its been a month since this was posted but you should do "vmArgs": "--module-path \"\" --add-modules javafx.controls,javafx.fxml"
@harshith_takkala
@harshith_takkala 4 жыл бұрын
@@0x5c yes you are right !
@badabeta6973
@badabeta6973 3 жыл бұрын
even Iam facing the same issue ! can anyone respond
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Hey, sorry for late reply but now I understood your problem. 1. "Error: Could not find or load main class app Caused by: java.lang.ClassNotFoundException: app" Solution: When u click the run button , VS code gives a warning, "The file app.java isn't on the classpath, the runtime may throw class not found error. Do you want to add the parent folder "APP/JavaFx Application/src" to Java source path?" Click yes. This warning is show only if you have installed "Debugger for Java" extension. If this warning is not shown by your VS code, then you can paste the below code in your settings.json, where you find the location of your jar files that you import. ``` "java.project.sourcePaths": [ "JavaFx Application/src" ] ``` If you have any other projects to add under this project, you can update this list accordingly. 2. After this you might me seeing one more error. "Error: JavaFX runtime components are missing, and are required to run this application" Solution: Fist, Debug your application's code. Can be done by "create a launch.json file" under "RUNAND DEBUG" of Explorer section. Add this vmArgs to the configuration which has the projectName in it. ``` "vmArgs": "--module-path D:\\Java_JFX\\javafx-sdk-14.0.2.1\\lib --add-modules javafx.controls,javafx.fxml", ``` It should be the path to the JavaFX lib folder. Then it will work. 👌✨ like anything !!
@hussanwaheed21
@hussanwaheed21 3 жыл бұрын
i'm still getting the Error: JavaFX runtime components are missing, and are required to run this application error
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Yeah, please check the pinned comment✌
@hussanwaheed21
@hussanwaheed21 3 жыл бұрын
@@harshith_takkala Yeah fixed it in a jiffy. i just had a major brain fart and was launching the wrong debug config.
@harshith_takkala
@harshith_takkala 3 жыл бұрын
@@hussanwaheed21 oh cool then.
@ganumba11
@ganumba11 4 жыл бұрын
Thank you, this worked.
@hellenfernandes8093
@hellenfernandes8093 4 жыл бұрын
Does it work for mac? "vmArgs": "--module-path D:\\Java_JFX\\javafx-sdk-14.0.2.1\\lib --add-modules javafx.controls,javafx.fxml",
@harshith_takkala
@harshith_takkala 4 жыл бұрын
I too have no idea. But I think the code snippet is based on VS code editor software but not based on OS. So I guess it might work..
@hellenfernandes8093
@hellenfernandes8093 4 жыл бұрын
Yeah, it doesnt wotk. I dont know what to do. Can you help me?
@harshith_takkala
@harshith_takkala 4 жыл бұрын
@@hellenfernandes8093 I also dont know, but I have followed in the similar way as described in the stackoverflow website. The screenshots were also taken from macbook. Link in description.
@harshith_takkala
@harshith_takkala 4 жыл бұрын
@@hellenfernandes8093 hey did u get it...?
@vicente3j
@vicente3j 2 жыл бұрын
Quick note on mac you use the "/" instead of "\\" otherwise good video, that error had me stuck for a while though
@datdat09
@datdat09 4 жыл бұрын
Thank you for your video, I am struggling with this. I followed your instruction; however, I still cannot run directly on vsc, I added vmArgs exactly as the instruction, but my terminal showed different from yours. It seems longer, shows every jars file in that lib, It also return one error "Could not find or load main class Files.AdoptOpenJDK.javafx-sdk-11.0.2.lib Caused by: java.lang.ClassNotFoundException: Files.AdoptOpenJDK.javafx-sdk-11.0.2.lib". I googled it but didn't find any answer, could you please help me with this? Really appreciate your efford. Thank you.
@harshith_takkala
@harshith_takkala 4 жыл бұрын
I think this might work(not sure) 1. Remove the lines 7 to 12 in launch.json and try again to run it. 2. Replace the word "Debug" in launch.jason with "CodeLens" in launch.json and try again to run. 3. I don't know what is AdoptOpenJDK. I have used Oracle JDK. I think this might help: adoptopenjdk.net/migration.html 4. I doubt you might have installed javafx separately in the system. "With the release of JDK 11 in 2018, Oracle has madeJavaFX part of the OpenJDK under the OpenJFX project." So according to this statement from wiki, installing separately again in yours(while using OpenJDK) might produce errors. This might also be helpful: stackoverflow.com/questions/18547362/javafx-and-openjdk developer.okta.com/blog/2019/01/16/which-java-sdk If nothing works, then I dont know because I am hearing AdoptOpenJDK word for the first time.😅 Thanks for the appreciation 🤝
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Hey, sorry for late reply but now I understood your problem. 1. "Error: Could not find or load main class app Caused by: java.lang.ClassNotFoundException: app" Solution: When u click the run button , VS code gives a warning, "The file app.java isn't on the classpath, the runtime may throw class not found error. Do you want to add the parent folder "APP/JavaFx Application/src" to Java source path?" Click yes. This warning is show only if you have installed "Debugger for Java" extension. If this warning is not shown by your VS code, then you can paste the below code in your settings.json, where you find the location of your jar files that you import. ``` "java.project.sourcePaths": [ "JavaFx Application/src" ] ``` If you have any other projects to add under this project, you can update this list accordingly. 2. After this you might me seeing one more error. "Error: JavaFX runtime components are missing, and are required to run this application" Solution: Fist, Debug your application's code. Can be done by "create a launch.json file" under "RUNAND DEBUG" of Explorer section. Add this vmArgs to the configuration which has the projectName in it. ``` "vmArgs": "--module-path D:\\Java_JFX\\javafx-sdk-14.0.2.1\\lib --add-modules javafx.controls,javafx.fxml", ``` It should be the path to the JavaFX lib folder. Then it will work. 👌✨ like anything !!
@datdat09
@datdat09 3 жыл бұрын
@@harshith_takkala haha ty, i deleted jdk, it was just for my project on university. But hope this cmt could help sone encounters the same prob. Anw, thank for your video.
@harshith_takkala
@harshith_takkala 3 жыл бұрын
@@datdat09 I too had assignment for the university. Many of my frds use eclipse or intellij. So I thought of doing like this.😁😄
@faizaaftab9813
@faizaaftab9813 3 жыл бұрын
I am getting 20 errors ☹️☹️☹️
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Ok, explain in brief plz
@cerant6423
@cerant6423 3 жыл бұрын
no me funciono
@harshith_takkala
@harshith_takkala 3 жыл бұрын
oh, lo siento por eso. Puedes ver mi otro video para el mismo, que es muy efectivo para compilar y ejecutar.
@harshith_takkala
@harshith_takkala 3 жыл бұрын
kzbin.info/www/bejne/i6uzd5-miNd6f5o This one
@harshith_takkala
@harshith_takkala 3 жыл бұрын
Hey, sorry for late reply but now I understood your problem. 1. "Error: Could not find or load main class app Caused by: java.lang.ClassNotFoundException: app" Solution: When u click the run button , VS code gives a warning, "The file app.java isn't on the classpath, the runtime may throw class not found error. Do you want to add the parent folder "APP/JavaFx Application/src" to Java source path?" Click yes. This warning is show only if you have installed "Debugger for Java" extension. If this warning is not shown by your VS code, then you can paste the below code in your settings.json, where you find the location of your jar files that you import. ``` "java.project.sourcePaths": [ "JavaFx Application/src" ] ``` If you have any other projects to add under this project, you can update this list accordingly. 2. After this you might me seeing one more error. "Error: JavaFX runtime components are missing, and are required to run this application" Solution: Fist, Debug your application's code. Can be done by "create a launch.json file" under "RUNAND DEBUG" of Explorer section. Add this vmArgs to the configuration which has the projectName in it. ``` "vmArgs": "--module-path D:\\Java_JFX\\javafx-sdk-14.0.2.1\\lib --add-modules javafx.controls,javafx.fxml", ``` It should be the path to the JavaFX lib folder. Then it will work. 👌✨ like anything !!
Zed “kills” VSCode
12:10
Alex Ziskind
Рет қаралды 914 М.
How to setup JavaFX Environment in Visual Studio Code?
14:32
Cool IT Help
Рет қаралды 109 М.
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
-5+3은 뭔가요? 📚 #shorts
0:19
5 분 Tricks
Рет қаралды 13 МЛН
Using Git & GitHub in VSCode: Stage, Commit, and Push
14:51
Max Rohowsky (Max on Tech)
Рет қаралды 83 М.
Setting up VS Code for GUI development using JavaFX.
10:47
Innovator
Рет қаралды 35 М.
How to ACTUALLY switch from VS Code to Neovim
5:09
Joshua Morony
Рет қаралды 282 М.
Sudden Strengthening of Ukraine / Massive Offensive
12:01
NEXTA Live
Рет қаралды 632 М.
Using Helix - Coming from VSCode (3 weeks in)
20:50
Mike Kelly
Рет қаралды 16 М.
Getting Started with Vim in Visual Studio Code
8:14
Suboptimal Engineer
Рет қаралды 204 М.
JavaFX Tutorial: Build Your First App in Java and JavaFX
5:02
Frank Delporte
Рет қаралды 863
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН