-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing Java in VS CODE shows way too much warnings! #1657
Writing Java in VS CODE shows way too much warnings! #1657
Comments
@lakshits11 You can try to add
to your your_project/.settings/org.eclipse.jdt.core.prefs |
I did that but still it is showing me squiggle line under there ! |
The .settings/org.eclipse.jdt.core.prefs file have to be placed to your project directory as follows:
Could you attach a project example? |
@lakshits11 Could you, please, attach a project example? |
You mean the zip file of my project ? If I am wrong, please help me to understand. |
Right. |
@snjeza I have an idea for why the Eclipse preference doesn't seem to be working. It seems that the language server won't recognize any Eclipse preferences under @lakshits11 An alternative way to get rid of warnings is with the package Exceptions;
@SuppressWarnings("serial")
public class MonthException extends Exception {
public MonthException(String s) {
super(s);
}
} The annotation is a way to explicitly ignore certain warnings from within your code, which means that even other people working on the same piece of code won't see the error, regardless of their editor settings. FYI the If I'm right about why the Eclipse preference to disable the warning doesn't work, I have another workaround you can try which is to add some files to initialize your project as an Eclipse project instead of an "invisible project". This way, the extension should be able to recognize Add a file called <?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>assignmentSix</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Also add a file called <?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Finally, after adding these two files, you should also restart VS Code. Did it work? |
@0dinD You are right. We should link the .settings directory to an "invisible project" too. |
@0dinD After adding |
@lakshits11 Yes, you should be able to ignore the warning without adding the I'm sure we'll find a fix for this in a future update, but in the meantime your best option is to convert the project into an Eclipse project, by following the instructions in my previous comment. If my instructions didn't work, I just realized there could be another action you'll have to take, which is to make sure the Java Language Server is running in "standard" mode. Please try the following:
Let me know if this works, I've based the solution on the assumption that you've enabled lightweight mode, since it's the most obvious reason I see for why my previous instruction didn't work. @snjeza Shouln't we also be able to detect Eclipse preferences when running in lightweight mode? It seems like an annoyance to have to switch to standard mode just because you want to ignore a warning or something similar. Also, should we track these problems with detecting Eclipse preferences in this issue (maybe we can rename it?), or should I create a new one for that? |
@0dinD I am sorry to say but it didn't worked 😥 . I am attaching a screenshot for reference. |
@lakshits11 The screenshot tells me that the Java Language Server is now running in standard mode, so it's strange to me that the warning still shows up. However, I just came to realize I forgot one small step in my instructions when I retraced my steps using the project you attached. Can you try running the command Java: Clean the Java language server workspace from the command palette (press This command will clean up workspace settings for the Java Language Server, which seems to be necessary after converting the project into an Eclipse project, in order for the After doing this, you should see the warning disappear (fingers crossed). Sorry it had to be this complicated, this is definitely a bug with invisible projects (and lightweight mode). |
@0dinD After I did what you told me to do , the curvy warning lines were gone, BUT ...wait wait wait, now when I run my App.java file using java test runner extension which comes in java extension pack, it was not able to recognize my MonthException and YearException java files and Build was failed in which error in the LOG file was MonthException and YearExceptioin cannot be ressolved to a type ! ALTHOUGH , the Date Exception was recognizable and it also created a DateException.class file as output ! I mean what the .... ? How funny and disgusting is it at the same time !! It is not showing any warning / curvy line now but I am pretty sure it all happened after clearing WorkSpace cache...before it, the code was running but the warning curvy lines were still there. I am attaching the screenshots for the same. ** 1. Here we can see that it's not showing any error/warning etc.** |
@lakshits11 could you attach your current project? |
@lakshits11 I can't reproduce the issue. |
Java Code in vs code shows way too much warnings. I mean these are really unnecessary warnings ! Even IDEs like IntelliJ don't show these unnecessary warnings. I want to disable such warnings, but not all the warnings. Is there a way to do so, or can you please do something about it ?
Environment
java 14.0.2 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
Steps To Reproduce
Download the folder below and open in vs code
assignmentSix.zip
Here we see that under MonthException we see a squiggle line with warning:
Warning Given:
The serializable class MonthException does not declare a static final serialVersionUID field of type longJava(536871008)
Even IDE like IntelliJ dont show these useless warnings...
So is there any way to disable these warnings _(NOT ALL WARNINGS)_ I mean can I only select what warnings I want to see and what I don't?
The text was updated successfully, but these errors were encountered: