vscode-java
vscode-java copied to clipboard
VSCode error javax.swing does not exist
Environment
- Operating System: MacOS Catalina
- JDK version: JAVA 8 Update 241
- Visual Studio Code version: Version: 1.42.1
- Java extension version: 0.8.1
Steps To Reproduce
I import as follows:-
import javax.swing.; // Error 'package javax.swing does not exist' import java.util.ArrayList; import java.io.; import java.util.StringTokenizer;
Causing error on 'JOptionPane' on every java files.
Current Result
- The IDE an Error on the 'import javax.swing.*' as 'package is not exist'
- Error on every 'JOptionPane' lines.
Additional Informations
Extension List:- Java Extension Pack Advance New File Better Comments Bracket Pair Colourizer Checkstyle for JAVA Code Runner Color Highlight Material Theme Error Lens GetHelp IntelliJ Keybindings Settings Sync Smart Multi Cursor Terminal Wakatime
@MuhammadimYusoff you may want to take a look at https://github.com/redhat-developer/vscode-java/issues/1147#issuecomment-554529618
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.
I can't reproduce the issue. Could you attach a project example?
https://pastebin.com/Nr6gkfda
I have place it on above link for you. I also have place the comment at first line.
@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.
I have the same problem. However, JOptionPane still works though.
Do I need to add javax.swing jars to classpath?
I am having the same problem. Any solution(s) ?
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" //],
----------SOLUTION----------
Go to settings.json and add the following lines:
"java.addExports": [ "javax.swing", "java.awt" ],
Then, restart Visual Studio Code !!
----------SOLUTIONS----------
Go to settings.json and add this:
"java.addExports": [ "javax.swing", "java.awt" ],
restart the vscode !!
This work perfectly . thanks a lot
----------SOLUTION----------
Go to settings.json and add the following lines:
"java.addExports": [ "javax.swing", "java.awt" ],
Then, restart Visual Studio Code !!
It works for me, Thanks
----------SOLUTION----------
Go to settings.json and add the following lines:
"java.addExports": [ "javax.swing", "java.awt" ],
Then, restart Visual Studio Code !!
It work for me too, Thanks !