You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried it but also failed, the 'import javax.swing.*' line still have error.
I have saved the settings.json, quit VSCode and open up VSCode again but the error still there.
BTW is 'javax.swing.' and 'java.awt.' both of them GUI related libraries?
Other threads says about conflicting libraries but I am not sure about this one.
@snjeza I think my system does not automatically set PATH for JVM, as per se the problem persist.
but as I am looking at my terminal nothing mentioned about JVM is not setup or related to it, but as I setup the PATH, the error still there, but at runtime the code running fine after I clean up the JAVA cache and all.
in vscode:
go to settings, search for java , scroll down to "Java › Completion: Favorite Static Members"
click in "edit in settings.json" and delete this peace of code(or comment it in case it doesn't work)
//"java.addExports": [
//"javax.swing",
//"java.awt"
//],
Reacted by SHADOW, loic_jiraud, Sylvain Júlio, MAX MILLIANO DE SOUZA MACHADO, Huijun-Hu, Jano, Hunter Rice, Lena Wu, ThomDion, Emomalijon (Emom) Murodzoda and 10 more
10. ----------SOLUTION----------
Go to settings.json and add the following lines:
"java.addExports": [
"javax.swing",
"java.awt"
],
Then, restart Visual Studio Code !!
This workaround seems to have fixed it for everyone, and is in fact the right thing to do.
Activity
snjeza commentedon Mar 1, 2020
@MuhammadimYusoff you may want to take a look at #1147 (comment)
MuhammadimYusoff commentedon Mar 1, 2020
I have tried it but also failed, the 'import javax.swing.*' line still have error.
I have saved the settings.json, quit VSCode and open up VSCode again but the error still there.
BTW is 'javax.swing.' and 'java.awt.' both of them GUI related libraries?
Other threads says about conflicting libraries but I am not sure about this one.
snjeza commentedon Mar 1, 2020
I can't reproduce the issue. Could you attach a project example?
MuhammadimYusoff commentedon Mar 2, 2020
https://pastebin.com/Nr6gkfda
I have place it on above link for you.
I also have place the comment at first line.
MuhammadimYusoff commentedon Mar 2, 2020
@snjeza I think my system does not automatically set PATH for JVM, as per se the problem persist.
but as I am looking at my terminal nothing mentioned about JVM is not setup or related to it, but as I setup the PATH, the error still there, but at runtime the code running fine after I clean up the JAVA cache and all.
Dameonn commentedon Oct 6, 2020
I have the same problem. However, JOptionPane still works though.
patricechaula commentedon Oct 13, 2020
Do I need to add javax.swing jars to classpath?
anserwaseem commentedon Mar 30, 2021
I am having the same problem. Any solution(s) ?
obahii commentedon May 14, 2022
in vscode:
go to settings, search for java , scroll down to "Java › Completion: Favorite Static Members"
click in "edit in settings.json" and delete this peace of code(or comment it in case it doesn't work)
//"java.addExports": [
//"javax.swing",
//"java.awt"
//],
billtsol commentedon Nov 17, 2022
----------SOLUTION----------
Go to settings.json and add the following lines:
"java.addExports": [
"javax.swing",
"java.awt"
],
Then, restart Visual Studio Code !!
Pasetop5 commentedon May 1, 2024
This work perfectly . thanks a lot
phurku commentedon May 23, 2024
It works for me, Thanks
heroldg commentedon Jan 4, 2025
It work for me too, Thanks !
robstryker commentedon Oct 29, 2026
This workaround seems to have fixed it for everyone, and is in fact the right thing to do.